From 1979bcb24e9efcaab595c4640e12e73de734bbce Mon Sep 17 00:00:00 2001 From: Laksh Singla Date: Tue, 31 Oct 2023 16:35:43 +0530 Subject: [PATCH] add changes for DoublesSketchListArgBaseOperatorConversion --- ...esSketchListArgBaseOperatorConversion.java | 2 +- .../sql/DoublesSketchSqlAggregatorTest.java | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchListArgBaseOperatorConversion.java b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchListArgBaseOperatorConversion.java index f5d46c9d5009..337586b1f941 100644 --- a/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchListArgBaseOperatorConversion.java +++ b/extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchListArgBaseOperatorConversion.java @@ -142,7 +142,7 @@ public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFail final RelDataType operandType = callBinding.getValidator().deriveType(callBinding.getScope(), operand); // Verify that 'operand' is a literal number. - if (!SqlUtil.isLiteral(operand)) { + if (!SqlUtil.isLiteral(operand, true)) { return OperatorConversions.throwOrReturn( throwOnFailure, callBinding, diff --git a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java index f85225d107d2..b39d3441b654 100644 --- a/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java +++ b/extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java @@ -495,6 +495,7 @@ public void testDoublesSketchPostAggs() + " DS_GET_QUANTILE(DS_QUANTILES_SKETCH(cnt + 123), 0.5) + 1000,\n" + " ABS(DS_GET_QUANTILE(DS_QUANTILES_SKETCH(cnt), 0.5)),\n" + " DS_GET_QUANTILES(DS_QUANTILES_SKETCH(cnt), 0.5, 0.8),\n" + + " DS_GET_QUANTILES(DS_QUANTILES_SKETCH(cnt), CAST(0.5 AS DOUBLE), CAST(0.8 AS DOUBLE)),\n" + " DS_HISTOGRAM(DS_QUANTILES_SKETCH(cnt), 0.2, 0.6),\n" + " DS_RANK(DS_QUANTILES_SKETCH(cnt), 3),\n" + " DS_CDF(DS_QUANTILES_SKETCH(cnt), 0.2, 0.6),\n" @@ -588,41 +589,49 @@ public void testDoublesSketchPostAggs() ), new double[]{0.5d, 0.8d} ), - new DoublesSketchToHistogramPostAggregator( + new DoublesSketchToQuantilesPostAggregator( "p13", new FieldAccessPostAggregator( "p12", "a2:agg" ), + new double[]{0.5d, 0.8d} + ), + new DoublesSketchToHistogramPostAggregator( + "p15", + new FieldAccessPostAggregator( + "p14", + "a2:agg" + ), new double[]{0.2d, 0.6d}, null ), new DoublesSketchToRankPostAggregator( - "p15", + "p17", new FieldAccessPostAggregator( - "p14", + "p16", "a2:agg" ), 3.0d ), new DoublesSketchToCDFPostAggregator( - "p17", + "p19", new FieldAccessPostAggregator( - "p16", + "p18", "a2:agg" ), new double[]{0.2d, 0.6d} ), new DoublesSketchToStringPostAggregator( - "p19", + "p21", new FieldAccessPostAggregator( - "p18", + "p20", "a2:agg" ) ), new ExpressionPostAggregator( - "p20", - "replace(replace(\"p19\",'HeapCompactDoublesSketch','HeapUpdateDoublesSketch')," + "p22", + "replace(replace(\"p21\",'HeapCompactDoublesSketch','HeapUpdateDoublesSketch')," + "'Combined Buffer Capacity : 6'," + "'Combined Buffer Capacity : 8')", null, @@ -640,6 +649,7 @@ public void testDoublesSketchPostAggs() 1124.0d, 1.0d, "[1.0,1.0]", + "[1.0,1.0]", "[0.0,0.0,6.0]", 1.0d, "[0.0,0.0,1.0]",