abhishekagarwal87 commented on code in PR #13819:
URL: https://github.com/apache/druid/pull/13819#discussion_r1122643836
##########
extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregationTest.java:
##########
@@ -1244,4 +1244,97 @@ public void buildingSketchesAtQueryTimeWithNullsTest()
throws Exception
Assert.assertEquals(0.0, ds3.getMinValue(), 0);
Assert.assertEquals(3.0, ds3.getMaxValue(), 0);
}
+
+
+ //Test ConstantTupleSketchPost-Agg and Base64 Encoding
+
+ @Test
+ public void testConstantAndBase64WithEstimateSumPostAgg() throws Exception
+ {
+ Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(
+ new
File(this.getClass().getClassLoader().getResource("tuple/array_of_doubles_sketch_data_two_values.tsv")
+ .getFile()),
+ String.join(
+ "\n",
+ "{",
+ " \"type\": \"string\",",
+ " \"parseSpec\": {",
+ " \"format\": \"tsv\",",
+ " \"timestampSpec\": {\"column\": \"timestamp\", \"format\":
\"yyyyMMddHH\"},",
+ " \"dimensionsSpec\": {",
+ " \"dimensions\": [\"product\"],",
+ " \"dimensionExclusions\": [],",
+ " \"spatialDimensions\": []",
+ " },",
+ " \"columns\": [\"timestamp\", \"product\", \"sketch\"]",
+ " }",
+ "}"
+ ),
+ String.join(
+ "\n",
+ "[",
+ " {\"type\": \"arrayOfDoublesSketch\", \"name\": \"sketch\",
\"fieldName\": \"sketch\", \"nominalEntries\": 1024, \"numberOfValues\": 2}",
+ "]"
+ ),
+ 0, // minTimestamp
+ Granularities.NONE,
+ 10, // maxRowCount
+ String.join(
+ "\n",
+ "{",
+ " \"queryType\": \"groupBy\",",
+ " \"dataSource\": \"test_datasource\",",
+ " \"granularity\": \"ALL\",",
+ " \"dimensions\": [],",
+ " \"aggregations\": [",
+ " {\"type\": \"arrayOfDoublesSketch\", \"name\": \"sketch\",
\"fieldName\": \"sketch\", \"nominalEntries\": 1024, \"numberOfValues\": 2}",
+ " ],",
+ " \"postAggregations\": [",
+ " {\"type\": \"arrayOfDoublesSketchToMetricsEstimate\",
\"name\": \"estimateSum\", \"field\": {\"type\": \"fieldAccess\",
\"fieldName\": \"sketch\"}},",
+ " {\"type\": \"arrayOfDoublesSketchToMetricsEstimate\",
\"name\": \"intersection\", \"field\": {",
Review Comment:
```suggestion
" {\"type\": \"arrayOfDoublesSketchToMetricsSumEstimate\",
\"name\": \"intersection\", \"field\": {",
```
##########
extensions-core/datasketches/src/main/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchModule.java:
##########
@@ -48,6 +48,13 @@ public class ArrayOfDoublesSketchModule implements
DruidModule
public static final ColumnType BUILD_TYPE =
ColumnType.ofComplex(ARRAY_OF_DOUBLES_SKETCH_BUILD_AGG);
public static final ColumnType MERGE_TYPE =
ColumnType.ofComplex(ARRAY_OF_DOUBLES_SKETCH_MERGE_AGG);
+ public static final String ARRAY_OF_DOUBLES_SKETCH_CONSTANT =
"arrayOfDoublesSketchConstant";
+
+ public static final String ARRAY_OF_DOUBLES_SKETCH_TO_BASE64_STRING =
"arrayOfDoublesSketchToBase64String";
+
+ public static final String ARRAY_OF_DOUBLES_SKETCH_METRICS_SUM_ESTIMATE =
"arrayOfDoublesSketchToMetricsEstimate";
Review Comment:
```suggestion
public static final String ARRAY_OF_DOUBLES_SKETCH_METRICS_SUM_ESTIMATE =
"arrayOfDoublesSketchToMetricsSumEstimate";
```
##########
extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/tuple/ArrayOfDoublesSketchAggregationTest.java:
##########
@@ -1244,4 +1244,97 @@ public void buildingSketchesAtQueryTimeWithNullsTest()
throws Exception
Assert.assertEquals(0.0, ds3.getMinValue(), 0);
Assert.assertEquals(3.0, ds3.getMaxValue(), 0);
}
+
+
+ //Test ConstantTupleSketchPost-Agg and Base64 Encoding
+
+ @Test
+ public void testConstantAndBase64WithEstimateSumPostAgg() throws Exception
+ {
+ Sequence<ResultRow> seq = helper.createIndexAndRunQueryOnSegment(
+ new
File(this.getClass().getClassLoader().getResource("tuple/array_of_doubles_sketch_data_two_values.tsv")
+ .getFile()),
+ String.join(
+ "\n",
+ "{",
+ " \"type\": \"string\",",
+ " \"parseSpec\": {",
+ " \"format\": \"tsv\",",
+ " \"timestampSpec\": {\"column\": \"timestamp\", \"format\":
\"yyyyMMddHH\"},",
+ " \"dimensionsSpec\": {",
+ " \"dimensions\": [\"product\"],",
+ " \"dimensionExclusions\": [],",
+ " \"spatialDimensions\": []",
+ " },",
+ " \"columns\": [\"timestamp\", \"product\", \"sketch\"]",
+ " }",
+ "}"
+ ),
+ String.join(
+ "\n",
+ "[",
+ " {\"type\": \"arrayOfDoublesSketch\", \"name\": \"sketch\",
\"fieldName\": \"sketch\", \"nominalEntries\": 1024, \"numberOfValues\": 2}",
+ "]"
+ ),
+ 0, // minTimestamp
+ Granularities.NONE,
+ 10, // maxRowCount
+ String.join(
+ "\n",
+ "{",
+ " \"queryType\": \"groupBy\",",
+ " \"dataSource\": \"test_datasource\",",
+ " \"granularity\": \"ALL\",",
+ " \"dimensions\": [],",
+ " \"aggregations\": [",
+ " {\"type\": \"arrayOfDoublesSketch\", \"name\": \"sketch\",
\"fieldName\": \"sketch\", \"nominalEntries\": 1024, \"numberOfValues\": 2}",
+ " ],",
+ " \"postAggregations\": [",
+ " {\"type\": \"arrayOfDoublesSketchToMetricsEstimate\",
\"name\": \"estimateSum\", \"field\": {\"type\": \"fieldAccess\",
\"fieldName\": \"sketch\"}},",
Review Comment:
```suggestion
" {\"type\": \"arrayOfDoublesSketchToMetricsSumEstimate\",
\"name\": \"estimateSum\", \"field\": {\"type\": \"fieldAccess\",
\"fieldName\": \"sketch\"}},",
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]