druid/extensions-core
Gian Merlino 8f90589ce5
Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH. (#13247)
* Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH.

These aggregation functions are documented as creating sketches. However,
they are planned into native aggregators that include finalization logic
to convert the sketch to a number of some sort. This creates an
inconsistency: the functions sometimes return sketches, and sometimes
return numbers, depending on where they lie in the native query plan.

This patch changes these SQL aggregators to _never_ finalize, by using
the "shouldFinalize" feature of the native aggregators. It already
existed for theta sketches. This patch adds the feature for hll and
quantiles sketches.

As to impact, Druid finalizes aggregators in two cases:

- When they appear in the outer level of a query (not a subquery).
- When they are used as input to an expression or finalizing-field-access
  post-aggregator (not any other kind of post-aggregator).

With this patch, the functions will no longer be finalized in these cases.

The second item is not likely to matter much. The SQL functions all declare
return type OTHER, which would be usable as an input to any other function
that makes sense and that would be planned into an expression.

So, the main effect of this patch is the first item. To provide backwards
compatibility with anyone that was depending on the old behavior, the
patch adds a "sqlFinalizeOuterSketches" query context parameter that
restores the old behavior.

Other changes:

1) Move various argument-checking logic from runtime to planning time in
   DoublesSketchListArgBaseOperatorConversion, by adding an OperandTypeChecker.

2) Add various JsonIgnores to the sketches to simplify their JSON representations.

3) Allow chaining of ExpressionPostAggregators and other PostAggregators
   in the SQL layer.

4) Avoid unnecessary FieldAccessPostAggregator wrapping in the SQL layer,
   now that expressions can operate on complex inputs.

5) Adjust return type to thetaSketch (instead of OTHER) in
   ThetaSketchSetBaseOperatorConversion.

* Fix benchmark class.

* Fix compilation error.

* Fix ThetaSketchSqlAggregatorTest.

* Hopefully fix ITAutoCompactionTest.

* Adjustment to ITAutoCompactionTest.
2022-11-03 09:43:00 -07:00
..
avro-extensions introduce a "tree" type to the flattenSpec (#12177) 2022-11-01 14:49:30 +08:00
azure-extensions Lazy initialization of segment killers, movers and archivers (#13170) 2022-10-04 15:55:46 +05:30
datasketches Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH. (#13247) 2022-11-03 09:43:00 -07:00
druid-aws-rds-extensions Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
druid-basic-security Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
druid-bloom-filter Modular Calcite Test Framework (#12965) 2022-10-20 15:45:44 -07:00
druid-kerberos Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
druid-pac4j Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
druid-ranger-security Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
ec2-extensions Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
google-extensions Lazy initialization of segment killers, movers and archivers (#13170) 2022-10-04 15:55:46 +05:30
hdfs-storage Lazy initialization of segment killers, movers and archivers (#13170) 2022-10-04 15:55:46 +05:30
histogram Modular Calcite Test Framework (#12965) 2022-10-20 15:45:44 -07:00
kafka-extraction-namespace Dependency cleanup (#13194) 2022-10-10 20:34:38 +08:00
kafka-indexing-service Support for middle manager less druid, tasks launch as k8s jobs (#13156) 2022-11-02 19:44:47 -07:00
kinesis-indexing-service Support for middle manager less druid, tasks launch as k8s jobs (#13156) 2022-11-02 19:44:47 -07:00
kubernetes-extensions Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
lookups-cached-global Use lookup memory footprint in MSQ memory computations. (#13271) 2022-11-03 07:36:54 -07:00
lookups-cached-single Use lookup memory footprint in MSQ memory computations. (#13271) 2022-11-03 07:36:54 -07:00
multi-stage-query Use lookup memory footprint in MSQ memory computations. (#13271) 2022-11-03 07:36:54 -07:00
mysql-metadata-storage Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
orc-extensions introduce a "tree" type to the flattenSpec (#12177) 2022-11-01 14:49:30 +08:00
parquet-extensions introduce a "tree" type to the flattenSpec (#12177) 2022-11-01 14:49:30 +08:00
postgresql-metadata-storage Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
protobuf-extensions Add inline descriptor Protobuf bytes decoder (#13192) 2022-10-11 13:37:28 -05:00
s3-extensions Support to read task logs from some S3 compatible cloud storage (#13195) 2022-10-15 10:44:23 +08:00
simple-client-sslcontext Bump up the version to 25.0.0 (#12975) 2022-08-29 11:27:38 +05:30
stats Modular Calcite Test Framework (#12965) 2022-10-20 15:45:44 -07:00
testing-tools more consistent expression error messages (#12995) 2022-09-06 23:21:38 -07:00