druid/docs/querying
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
..
aggregations.md stringFirst and stringLast supported in ingestion (#12466) 2022-04-22 10:28:49 +08:00
caching.md Docs - query caching (#11584) 2022-04-18 17:00:21 +08:00
datasource.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
datasourcemetadataquery.md Refresh query docs. (#9704) 2020-04-15 16:12:20 -07:00
dimensionspecs.md Various documentation updates. (#13107) 2022-09-16 21:58:11 -07:00
filters.md Adjust "in" filter null behavior to match "selector". (#12863) 2022-08-08 09:08:36 -07:00
granularities.md Document missed simple granularities (#12768) 2022-07-14 14:02:28 +08:00
groupbyquery.md document virtualColumns in native query documentation, fix some redirects (#12917) 2022-08-18 20:49:23 -07:00
having.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
hll-old.md De-incubation cleanup in code, docs, packaging (#9108) 2020-01-03 12:33:19 -05:00
joins.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
limitspec.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
lookups.md Fix documentation bug about injective lookups (#13147) 2022-09-27 10:16:48 +08:00
multi-value-dimensions.md Adding new config for disabling group by on multiValue column (#12253) 2022-02-16 20:53:26 +05:30
multitenancy.md Addition to Multitenancy considerations doc (#12567) 2022-06-02 10:32:14 -07:00
nested-columns.md Update nested-columns.md (#13227) 2022-10-14 16:15:46 -07:00
post-aggregations.md Document expression post-aggregators (#11896) 2022-04-19 10:36:19 +08:00
query-context.md Docs: update description of query priority default value (#13191) 2022-10-14 14:28:04 -07:00
query-execution.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
querying.md Various documentation updates. (#13107) 2022-09-16 21:58:11 -07:00
scan-query.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
searchquery.md document virtualColumns in native query documentation, fix some redirects (#12917) 2022-08-18 20:49:23 -07:00
segmentmetadataquery.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
select-query.md Add "offset" parameter to the Scan query. (#10233) 2020-08-13 14:56:24 -07:00
sorting-orders.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
sql-aggregations.md Clarified the behaviour of SQL COUNT(DISTINCT dim) on multi-value dimensions (#13128) 2022-09-20 18:03:34 -07:00
sql-api.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
sql-data-types.md Nested columns documentation (#12946) 2022-09-06 14:42:18 -07:00
sql-functions.md basic docs for nested column query functions (#12922) 2022-08-19 17:12:19 -07:00
sql-jdbc.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
sql-json-functions.md Various documentation updates. (#13107) 2022-09-16 21:58:11 -07:00
sql-metadata-tables.md SQL: Add is_active to sys.segments, update examples and docs. (#11550) 2022-05-19 14:23:28 -07:00
sql-multivalue-string-functions.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
sql-operators.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
sql-query-context.md Always return sketches from DS_HLL, DS_THETA, DS_QUANTILES_SKETCH. (#13247) 2022-11-03 09:43:00 -07:00
sql-scalar.md Add TIME_IN_INTERVAL SQL operator. (#12662) 2022-06-21 13:05:37 -07:00
sql-translation.md remove mentions of DruidQueryRel from docs (#13033) 2022-09-06 13:37:27 -07:00
sql.md IMPLY-12348: Update description of UNION ALL in SQL syntax doc (#12710) 2022-07-05 13:08:01 -07:00
timeboundaryquery.md Refresh query docs. (#9704) 2020-04-15 16:12:20 -07:00
timeseriesquery.md document virtualColumns in native query documentation, fix some redirects (#12917) 2022-08-18 20:49:23 -07:00
topnmetricspec.md Sql docs items (#12530) 2022-05-17 16:56:31 -07:00
topnquery.md document virtualColumns in native query documentation, fix some redirects (#12917) 2022-08-18 20:49:23 -07:00
troubleshooting.md Refactor SQL docs (#12239) 2022-02-11 14:43:30 -08:00
using-caching.md Docs - query caching (#11584) 2022-04-18 17:00:21 +08:00
virtual-columns.md Nested columns documentation (#12946) 2022-09-06 14:42:18 -07:00