Skip to content

Commit 41712b7

Browse files
authored
Refactor SqlLifecycle into statement classes (#12845)
* Refactor SqlLifecycle into statement classes Create direct & prepared statements Remove redundant exceptions from tests Tidy up Calcite query tests Make PlannerConfig more testable * Build fixes * Added builder to SqlQueryPlus * Moved Calcites system properties to saffron.properties * Build fix * Resolve merge conflict * Fix IntelliJ inspection issue * Revisions from reviews Backed out a revision to Calcite tests that didn't work out as planned * Build fix * Fixed spelling errors * Fixed failed test Prepare now enforces security; before it did not. * Rebase and fix IntelliJ inspections issue * Clean up exception handling * Fix handling of JDBC auth errors * Build fix * More tweaks to security messages
1 parent 4d65c08 commit 41712b7

File tree

76 files changed

+3159
-2578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+3159
-2578
lines changed

benchmarks/src/test/java/org/apache/druid/benchmark/query/SqlBenchmark.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import org.apache.druid.sql.calcite.expression.SqlOperatorConversion;
4949
import org.apache.druid.sql.calcite.expression.builtin.QueryLookupOperatorConversion;
5050
import org.apache.druid.sql.calcite.planner.CalciteRulesManager;
51-
import org.apache.druid.sql.calcite.planner.Calcites;
5251
import org.apache.druid.sql.calcite.planner.DruidOperatorTable;
5352
import org.apache.druid.sql.calcite.planner.DruidPlanner;
5453
import org.apache.druid.sql.calcite.planner.PlannerConfig;
@@ -75,6 +74,7 @@
7574
import org.openjdk.jmh.infra.Blackhole;
7675

7776
import javax.annotation.Nullable;
77+
7878
import java.util.HashSet;
7979
import java.util.List;
8080
import java.util.Map;
@@ -92,7 +92,6 @@ public class SqlBenchmark
9292
{
9393
static {
9494
NullHandling.initializeForTests();
95-
Calcites.setSystemProperties();
9695
}
9796

9897
private static final Logger log = new Logger(SqlBenchmark.class);

benchmarks/src/test/java/org/apache/druid/benchmark/query/SqlExpressionBenchmark.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.apache.druid.server.security.AuthTestUtils;
4040
import org.apache.druid.sql.calcite.SqlVectorizedExpressionSanityTest;
4141
import org.apache.druid.sql.calcite.planner.CalciteRulesManager;
42-
import org.apache.druid.sql.calcite.planner.Calcites;
4342
import org.apache.druid.sql.calcite.planner.DruidPlanner;
4443
import org.apache.druid.sql.calcite.planner.PlannerConfig;
4544
import org.apache.druid.sql.calcite.planner.PlannerFactory;
@@ -65,6 +64,7 @@
6564
import org.openjdk.jmh.infra.Blackhole;
6665

6766
import javax.annotation.Nullable;
67+
6868
import java.util.List;
6969
import java.util.Map;
7070
import java.util.concurrent.TimeUnit;
@@ -82,7 +82,6 @@ public class SqlExpressionBenchmark
8282

8383
static {
8484
NullHandling.initializeForTests();
85-
Calcites.setSystemProperties();
8685
ExpressionProcessing.initializeForStrictBooleansTests(true);
8786
}
8887

benchmarks/src/test/java/org/apache/druid/benchmark/query/SqlNestedDataBenchmark.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.apache.druid.server.security.AuthTestUtils;
4646
import org.apache.druid.sql.calcite.SqlVectorizedExpressionSanityTest;
4747
import org.apache.druid.sql.calcite.planner.CalciteRulesManager;
48-
import org.apache.druid.sql.calcite.planner.Calcites;
4948
import org.apache.druid.sql.calcite.planner.DruidPlanner;
5049
import org.apache.druid.sql.calcite.planner.PlannerConfig;
5150
import org.apache.druid.sql.calcite.planner.PlannerFactory;
@@ -71,6 +70,7 @@
7170
import org.openjdk.jmh.infra.Blackhole;
7271

7372
import javax.annotation.Nullable;
73+
7474
import java.util.List;
7575
import java.util.Map;
7676
import java.util.concurrent.TimeUnit;
@@ -85,7 +85,6 @@ public class SqlNestedDataBenchmark
8585

8686
static {
8787
NullHandling.initializeForTests();
88-
Calcites.setSystemProperties();
8988
ExpressionProcessing.initializeForStrictBooleansTests(true);
9089
}
9190

extensions-contrib/tdigestsketch/src/test/java/org/apache/druid/query/aggregation/tdigestsketch/sql/TDigestSketchSqlAggregatorTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public DruidOperatorTable createOperatorTable()
117117
}
118118

119119
@Test
120-
public void testComputingSketchOnNumericValues() throws Exception
120+
public void testComputingSketchOnNumericValues()
121121
{
122122
cannotVectorize();
123123

@@ -145,7 +145,7 @@ public void testComputingSketchOnNumericValues() throws Exception
145145
}
146146

147147
@Test
148-
public void testComputingSketchOnCastedString() throws Exception
148+
public void testComputingSketchOnCastedString()
149149
{
150150
cannotVectorize();
151151

@@ -185,7 +185,7 @@ public void testComputingSketchOnCastedString() throws Exception
185185
}
186186

187187
@Test
188-
public void testDefaultCompressionForTDigestGenerateSketchAgg() throws Exception
188+
public void testDefaultCompressionForTDigestGenerateSketchAgg()
189189
{
190190
cannotVectorize();
191191

@@ -211,7 +211,7 @@ public void testDefaultCompressionForTDigestGenerateSketchAgg() throws Exception
211211
}
212212

213213
@Test
214-
public void testComputingQuantileOnPreAggregatedSketch() throws Exception
214+
public void testComputingQuantileOnPreAggregatedSketch()
215215
{
216216
cannotVectorize();
217217

@@ -253,7 +253,7 @@ public void testComputingQuantileOnPreAggregatedSketch() throws Exception
253253
}
254254

255255
@Test
256-
public void testGeneratingSketchAndComputingQuantileOnFly() throws Exception
256+
public void testGeneratingSketchAndComputingQuantileOnFly()
257257
{
258258
cannotVectorize();
259259

@@ -308,7 +308,7 @@ public void testGeneratingSketchAndComputingQuantileOnFly() throws Exception
308308
}
309309

310310
@Test
311-
public void testQuantileOnNumericValues() throws Exception
311+
public void testQuantileOnNumericValues()
312312
{
313313
cannotVectorize();
314314

@@ -345,7 +345,7 @@ public void testQuantileOnNumericValues() throws Exception
345345
}
346346

347347
@Test
348-
public void testCompressionParamForTDigestQuantileAgg() throws Exception
348+
public void testCompressionParamForTDigestQuantileAgg()
349349
{
350350
cannotVectorize();
351351
testQuery(
@@ -383,7 +383,7 @@ public void testCompressionParamForTDigestQuantileAgg() throws Exception
383383
}
384384

385385
@Test
386-
public void testQuantileOnCastedString() throws Exception
386+
public void testQuantileOnCastedString()
387387
{
388388
cannotVectorize();
389389

@@ -436,7 +436,7 @@ public void testQuantileOnCastedString() throws Exception
436436
}
437437

438438
@Test
439-
public void testEmptyTimeseriesResults() throws Exception
439+
public void testEmptyTimeseriesResults()
440440
{
441441
cannotVectorize();
442442

@@ -468,7 +468,7 @@ public void testEmptyTimeseriesResults() throws Exception
468468
}
469469

470470
@Test
471-
public void testGroupByAggregatorDefaultValues() throws Exception
471+
public void testGroupByAggregatorDefaultValues()
472472
{
473473
cannotVectorize();
474474
testQuery(

extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/hll/sql/HllSketchSqlAggregatorTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public Iterable<? extends Module> getJacksonModules()
8585
return Iterables.concat(super.getJacksonModules(), new HllSketchModule().getJacksonModules());
8686
}
8787

88+
@SuppressWarnings("resource")
8889
@Override
8990
public SpecificSegmentsQuerySegmentWalker createQuerySegmentWalker() throws IOException
9091
{
@@ -149,7 +150,7 @@ public DruidOperatorTable createOperatorTable()
149150
}
150151

151152
@Test
152-
public void testApproxCountDistinctHllSketch() throws Exception
153+
public void testApproxCountDistinctHllSketch()
153154
{
154155
// Can't vectorize due to SUBSTRING expression.
155156
cannotVectorize();
@@ -244,7 +245,7 @@ public void testApproxCountDistinctHllSketch() throws Exception
244245

245246

246247
@Test
247-
public void testAvgDailyCountDistinctHllSketch() throws Exception
248+
public void testAvgDailyCountDistinctHllSketch()
248249
{
249250
// Can't vectorize due to outer query, which runs on an inline datasource.
250251
cannotVectorize();
@@ -340,7 +341,7 @@ public void testAvgDailyCountDistinctHllSketch() throws Exception
340341
}
341342

342343
@Test
343-
public void testApproxCountDistinctHllSketchIsRounded() throws Exception
344+
public void testApproxCountDistinctHllSketchIsRounded()
344345
{
345346
testQuery(
346347
"SELECT"
@@ -376,7 +377,7 @@ public void testApproxCountDistinctHllSketchIsRounded() throws Exception
376377
}
377378

378379
@Test
379-
public void testHllSketchPostAggs() throws Exception
380+
public void testHllSketchPostAggs()
380381
{
381382
final String sketchSummary = "### HLL SKETCH SUMMARY: \n"
382383
+ " Log Config K : 12\n"
@@ -528,7 +529,7 @@ public void testHllSketchPostAggs() throws Exception
528529
}
529530

530531
@Test
531-
public void testtHllSketchPostAggsPostSort() throws Exception
532+
public void testtHllSketchPostAggsPostSort()
532533
{
533534
final String sketchSummary = "### HLL SKETCH SUMMARY: \n"
534535
+ " Log Config K : 12\n"
@@ -582,7 +583,7 @@ public void testtHllSketchPostAggsPostSort() throws Exception
582583
}
583584

584585
@Test
585-
public void testEmptyTimeseriesResults() throws Exception
586+
public void testEmptyTimeseriesResults()
586587
{
587588
// timeseries with all granularity have a single group, so should return default results for given aggregators
588589
testQuery(
@@ -620,7 +621,7 @@ public void testEmptyTimeseriesResults() throws Exception
620621
}
621622

622623
@Test
623-
public void testGroupByAggregatorDefaultValues() throws Exception
624+
public void testGroupByAggregatorDefaultValues()
624625
{
625626
testQuery(
626627
"SELECT\n"

extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public DruidOperatorTable createOperatorTable()
140140
}
141141

142142
@Test
143-
public void testQuantileOnFloatAndLongs() throws Exception
143+
public void testQuantileOnFloatAndLongs()
144144
{
145145
testQuery(
146146
"SELECT\n"
@@ -213,7 +213,7 @@ public void testQuantileOnFloatAndLongs() throws Exception
213213
}
214214

215215
@Test
216-
public void testQuantileOnComplexColumn() throws Exception
216+
public void testQuantileOnComplexColumn()
217217
{
218218
testQuery(
219219
"SELECT\n"
@@ -270,7 +270,7 @@ public void testQuantileOnComplexColumn() throws Exception
270270
}
271271

272272
@Test
273-
public void testQuantileOnCastedString() throws Exception
273+
public void testQuantileOnCastedString()
274274
{
275275
final List<Object[]> expectedResults;
276276
if (NullHandling.replaceWithDefault()) {
@@ -363,7 +363,7 @@ public void testQuantileOnCastedString() throws Exception
363363
}
364364

365365
@Test
366-
public void testQuantileOnInnerQuery() throws Exception
366+
public void testQuantileOnInnerQuery()
367367
{
368368
final List<Object[]> expectedResults;
369369
if (NullHandling.replaceWithDefault()) {
@@ -429,7 +429,7 @@ public void testQuantileOnInnerQuery() throws Exception
429429
}
430430

431431
@Test
432-
public void testQuantileOnInnerQuantileQuery() throws Exception
432+
public void testQuantileOnInnerQuantileQuery()
433433
{
434434
ImmutableList.Builder<Object[]> builder = ImmutableList.builder();
435435
builder.add(new Object[]{"", 1.0});
@@ -496,7 +496,7 @@ public void testQuantileOnInnerQuantileQuery() throws Exception
496496
}
497497

498498
@Test
499-
public void testDoublesSketchPostAggs() throws Exception
499+
public void testDoublesSketchPostAggs()
500500
{
501501
testQuery(
502502
"SELECT\n"
@@ -679,7 +679,7 @@ public void testDoublesSketchPostAggs() throws Exception
679679
}
680680

681681
@Test
682-
public void testDoublesSketchPostAggsPostSort() throws Exception
682+
public void testDoublesSketchPostAggsPostSort()
683683
{
684684
testQuery(
685685
"SELECT DS_GET_QUANTILE(y, 0.5), DS_GET_QUANTILE(y, 0.98) from ("
@@ -728,7 +728,7 @@ public void testDoublesSketchPostAggsPostSort() throws Exception
728728
}
729729

730730
@Test
731-
public void testEmptyTimeseriesResults() throws Exception
731+
public void testEmptyTimeseriesResults()
732732
{
733733
testQuery(
734734
"SELECT\n"
@@ -768,7 +768,7 @@ public void testEmptyTimeseriesResults() throws Exception
768768
}
769769

770770
@Test
771-
public void testGroupByAggregatorDefaultValues() throws Exception
771+
public void testGroupByAggregatorDefaultValues()
772772
{
773773
testQuery(
774774
"SELECT\n"
@@ -828,7 +828,7 @@ public void testGroupByAggregatorDefaultValues() throws Exception
828828
}
829829

830830
@Test
831-
public void testSuccessWithSmallMaxStreamLength() throws Exception
831+
public void testSuccessWithSmallMaxStreamLength()
832832
{
833833
final Map<String, Object> context = new HashMap<>(QUERY_CONTEXT_DEFAULT);
834834
context.put(

extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/theta/sql/ThetaSketchSqlAggregatorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public DruidOperatorTable createOperatorTable()
145145
}
146146

147147
@Test
148-
public void testApproxCountDistinctThetaSketch() throws Exception
148+
public void testApproxCountDistinctThetaSketch()
149149
{
150150
// Cannot vectorize due to SUBSTRING.
151151
cannotVectorize();
@@ -265,7 +265,7 @@ public void testApproxCountDistinctThetaSketch() throws Exception
265265
}
266266

267267
@Test
268-
public void testAvgDailyCountDistinctThetaSketch() throws Exception
268+
public void testAvgDailyCountDistinctThetaSketch()
269269
{
270270
// Can't vectorize due to outer query (it operates on an inlined data source, which cannot be vectorized).
271271
cannotVectorize();
@@ -359,7 +359,7 @@ public void testAvgDailyCountDistinctThetaSketch() throws Exception
359359
}
360360

361361
@Test
362-
public void testThetaSketchPostAggs() throws Exception
362+
public void testThetaSketchPostAggs()
363363
{
364364
final List<Object[]> expectedResults;
365365

@@ -529,7 +529,7 @@ public void testThetaSketchPostAggs() throws Exception
529529
}
530530

531531
@Test
532-
public void testThetaSketchPostAggsPostSort() throws Exception
532+
public void testThetaSketchPostAggsPostSort()
533533
{
534534
final String sql = "SELECT DS_THETA(dim2) as y FROM druid.foo ORDER BY THETA_SKETCH_ESTIMATE(DS_THETA(dim2)) DESC LIMIT 10";
535535

@@ -579,7 +579,7 @@ public void testThetaSketchPostAggsPostSort() throws Exception
579579
}
580580

581581
@Test
582-
public void testEmptyTimeseriesResults() throws Exception
582+
public void testEmptyTimeseriesResults()
583583
{
584584
testQuery(
585585
"SELECT\n"
@@ -638,7 +638,7 @@ public void testEmptyTimeseriesResults() throws Exception
638638
}
639639

640640
@Test
641-
public void testGroupByAggregatorDefaultValues() throws Exception
641+
public void testGroupByAggregatorDefaultValues()
642642
{
643643
testQuery(
644644
"SELECT\n"

0 commit comments

Comments
 (0)