|
| 1 | +package sqlancer.doris; |
| 2 | + |
| 3 | +import java.sql.SQLException; |
| 4 | +import java.util.ArrayList; |
| 5 | +import java.util.Arrays; |
| 6 | +import java.util.List; |
| 7 | + |
| 8 | +import com.beust.jcommander.Parameter; |
| 9 | +import com.beust.jcommander.Parameters; |
| 10 | + |
| 11 | +import sqlancer.DBMSSpecificOptions; |
| 12 | +import sqlancer.OracleFactory; |
| 13 | +import sqlancer.common.oracle.CompositeTestOracle; |
| 14 | +import sqlancer.common.oracle.TestOracle; |
| 15 | +import sqlancer.doris.DorisOptions.DorisOracleFactory; |
| 16 | +import sqlancer.doris.DorisProvider.DorisGlobalState; |
| 17 | +import sqlancer.doris.oracle.DorisNoRECOracle; |
| 18 | +import sqlancer.doris.oracle.DorisPivotedQuerySynthesisOracle; |
| 19 | +import sqlancer.doris.oracle.tlp.DorisQueryPartitioningAggregateTester; |
| 20 | +import sqlancer.doris.oracle.tlp.DorisQueryPartitioningDistinctTester; |
| 21 | +import sqlancer.doris.oracle.tlp.DorisQueryPartitioningGroupByTester; |
| 22 | +import sqlancer.doris.oracle.tlp.DorisQueryPartitioningHavingTester; |
| 23 | +import sqlancer.doris.oracle.tlp.DorisQueryPartitioningWhereTester; |
| 24 | + |
| 25 | +@Parameters(commandDescription = "Apache Doris (default port: " + DorisOptions.DEFAULT_PORT + ", default host: " |
| 26 | + + DorisOptions.DEFAULT_HOST + ")") |
| 27 | +public class DorisOptions implements DBMSSpecificOptions<DorisOracleFactory> { |
| 28 | + public static final String DEFAULT_HOST = "localhost"; |
| 29 | + public static final int DEFAULT_PORT = 9030; |
| 30 | + |
| 31 | + @Parameter(names = { "--max-num-tables" }, description = "The maximum number of tables/views that can be created") |
| 32 | + public int maxNumTables = 10; |
| 33 | + |
| 34 | + @Parameter(names = { "--max-num-indexes" }, description = "The maximum number of indexes that can be created") |
| 35 | + public int maxNumIndexes = 20; |
| 36 | + |
| 37 | + @Parameter(names = "--test-default-values", description = "Allow generating DEFAULT values in tables", arity = 1) |
| 38 | + public boolean testDefaultValues = true; |
| 39 | + |
| 40 | + @Parameter(names = "--test-not-null", description = "Allow generating NOT NULL constraints in tables", arity = 1) |
| 41 | + public boolean testNotNullConstraints = true; |
| 42 | + |
| 43 | + @Parameter(names = "--test-functions", description = "Allow generating functions in expressions", arity = 1) |
| 44 | + public boolean testFunctions; |
| 45 | + |
| 46 | + @Parameter(names = "--test-casts", description = "Allow generating casts in expressions", arity = 1) |
| 47 | + public boolean testCasts = true; |
| 48 | + |
| 49 | + @Parameter(names = "--test-between", description = "Allow generating the BETWEEN operator in expressions", arity = 1) |
| 50 | + public boolean testBetween = true; |
| 51 | + |
| 52 | + @Parameter(names = "--test-in", description = "Allow generating the IN operator in expressions", arity = 1) |
| 53 | + public boolean testIn = true; |
| 54 | + |
| 55 | + @Parameter(names = "--test-case", description = "Allow generating the CASE operator in expressions", arity = 1) |
| 56 | + public boolean testCase = true; |
| 57 | + |
| 58 | + @Parameter(names = "--test-binary-logicals", description = "Allow generating AND and OR in expressions", arity = 1) |
| 59 | + public boolean testBinaryLogicals = true; |
| 60 | + |
| 61 | + @Parameter(names = "--test-int-constants", description = "Allow generating INTEGER constants", arity = 1) |
| 62 | + public boolean testIntConstants = true; |
| 63 | + |
| 64 | + @Parameter(names = "--test-float-constants", description = "Allow generating floating-point constants", arity = 1) |
| 65 | + public boolean testFloatConstants = true; |
| 66 | + |
| 67 | + @Parameter(names = "--test-decimal-constants", description = "Allow generating DECIMAL constants", arity = 1) |
| 68 | + public boolean testDecimalConstants = true; |
| 69 | + |
| 70 | + @Parameter(names = "--test-date-constants", description = "Allow generating DATE constants", arity = 1) |
| 71 | + public boolean testDateConstants = true; |
| 72 | + |
| 73 | + @Parameter(names = "--test-datetime-constants", description = "Allow generating DATETIME constants", arity = 1) |
| 74 | + public boolean testDateTimeConstants = true; |
| 75 | + |
| 76 | + @Parameter(names = "--test-varchar-constants", description = "Allow generating VARCHAR constants", arity = 1) |
| 77 | + public boolean testStringConstants = true; |
| 78 | + |
| 79 | + @Parameter(names = "--test-boolean-constants", description = "Allow generating boolean constants", arity = 1) |
| 80 | + public boolean testBooleanConstants = true; |
| 81 | + |
| 82 | + @Parameter(names = "--test-binary-comparisons", description = "Allow generating binary comparison operators (e.g., >= or LIKE)", arity = 1) |
| 83 | + public boolean testBinaryComparisons = true; |
| 84 | + |
| 85 | + @Parameter(names = "--max-num-deletes", description = "The maximum number of DELETE statements that are issued for a database", arity = 1) |
| 86 | + public int maxNumDeletes = 1; |
| 87 | + |
| 88 | + @Parameter(names = "--max-num-updates", description = "The maximum number of UPDATE statements that are issued for a database", arity = 1) |
| 89 | + public int maxNumUpdates; |
| 90 | + |
| 91 | + @Parameter(names = "--max-num-table-alters", description = "The maximum number of ALTER TABLE statements that are issued for a database", arity = 1) |
| 92 | + public int maxNumTableAlters; |
| 93 | + |
| 94 | + @Parameter(names = "--test-engine-type", description = "The engine type in Doris, only consider OLAP now", arity = 1) |
| 95 | + public String testEngineType = "OLAP"; // skip now |
| 96 | + |
| 97 | + @Parameter(names = "--test-indexes", description = "Allow explicit indexes, Doris only supports creating indexes on single-column BITMAP", arity = 1) |
| 98 | + public boolean testIndexes = true; // skip now |
| 99 | + |
| 100 | + @Parameter(names = "--test-column-aggr", description = "Allow test column aggregation (sum, min, max, replace, replace_if_not_null, hll_union, bitmap_untion)", arity = 1) |
| 101 | + public boolean testColumnAggr = true; |
| 102 | + |
| 103 | + @Parameter(names = "--test-datemodel", description = "Allow generating Doris’s data model in tables. (Aggregate、Uniqe、Duplicate)", arity = 1) |
| 104 | + public boolean testDataModel = true; |
| 105 | + |
| 106 | + @Parameter(names = "--test-distribution", description = "Allow generating data distribution in tables.", arity = 1) |
| 107 | + public boolean testDistribution = true; // must have it, skip now |
| 108 | + |
| 109 | + @Parameter(names = "--test-rollup", description = "Allow generating rollups in tables.", arity = 1) |
| 110 | + public boolean testRollup = true; // skip now |
| 111 | + |
| 112 | + @Parameter(names = "--oracle") |
| 113 | + public List<DorisOracleFactory> oracles = Arrays.asList(DorisOracleFactory.NOREC); |
| 114 | + |
| 115 | + public enum DorisOracleFactory implements OracleFactory<DorisGlobalState> { |
| 116 | + NOREC { |
| 117 | + @Override |
| 118 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 119 | + return new DorisNoRECOracle(globalState); |
| 120 | + } |
| 121 | + |
| 122 | + }, |
| 123 | + HAVING { |
| 124 | + @Override |
| 125 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 126 | + return new DorisQueryPartitioningHavingTester(globalState); |
| 127 | + } |
| 128 | + }, |
| 129 | + WHERE { |
| 130 | + @Override |
| 131 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 132 | + return new DorisQueryPartitioningWhereTester(globalState); |
| 133 | + } |
| 134 | + }, |
| 135 | + GROUP_BY { |
| 136 | + @Override |
| 137 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 138 | + return new DorisQueryPartitioningGroupByTester(globalState); |
| 139 | + } |
| 140 | + }, |
| 141 | + AGGREGATE { |
| 142 | + @Override |
| 143 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 144 | + return new DorisQueryPartitioningAggregateTester(globalState); |
| 145 | + } |
| 146 | + |
| 147 | + }, |
| 148 | + DISTINCT { |
| 149 | + @Override |
| 150 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 151 | + return new DorisQueryPartitioningDistinctTester(globalState); |
| 152 | + } |
| 153 | + }, |
| 154 | + QUERY_PARTITIONING { |
| 155 | + @Override |
| 156 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws SQLException { |
| 157 | + List<TestOracle<DorisGlobalState>> oracles = new ArrayList<>(); |
| 158 | + oracles.add(new DorisQueryPartitioningWhereTester(globalState)); |
| 159 | + oracles.add(new DorisQueryPartitioningHavingTester(globalState)); |
| 160 | + oracles.add(new DorisQueryPartitioningAggregateTester(globalState)); |
| 161 | + oracles.add(new DorisQueryPartitioningDistinctTester(globalState)); |
| 162 | + oracles.add(new DorisQueryPartitioningGroupByTester(globalState)); |
| 163 | + return new CompositeTestOracle<DorisGlobalState>(oracles, globalState); |
| 164 | + } |
| 165 | + }, |
| 166 | + PQS { |
| 167 | + @Override |
| 168 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws Exception { |
| 169 | + return new DorisPivotedQuerySynthesisOracle(globalState); |
| 170 | + } |
| 171 | + }, |
| 172 | + ALL { |
| 173 | + @Override |
| 174 | + public TestOracle<DorisGlobalState> create(DorisGlobalState globalState) throws Exception { |
| 175 | + List<TestOracle<DorisGlobalState>> oracles = new ArrayList<>(); |
| 176 | + oracles.add(new DorisNoRECOracle(globalState)); |
| 177 | + oracles.add(new DorisQueryPartitioningWhereTester(globalState)); |
| 178 | + oracles.add(new DorisQueryPartitioningHavingTester(globalState)); |
| 179 | + oracles.add(new DorisQueryPartitioningAggregateTester(globalState)); |
| 180 | + oracles.add(new DorisQueryPartitioningDistinctTester(globalState)); |
| 181 | + oracles.add(new DorisQueryPartitioningGroupByTester(globalState)); |
| 182 | + oracles.add(new DorisPivotedQuerySynthesisOracle(globalState)); |
| 183 | + return new CompositeTestOracle<DorisGlobalState>(oracles, globalState); |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + } |
| 188 | + |
| 189 | + @Override |
| 190 | + public List<DorisOracleFactory> getTestOracleFactory() { |
| 191 | + return oracles; |
| 192 | + } |
| 193 | + |
| 194 | +} |
0 commit comments