druid/docs
Gian Merlino 82f7a56475
Sort-merge join and hash shuffles for MSQ. (#13506)
* Sort-merge join and hash shuffles for MSQ.

The main changes are in the processing, multi-stage-query, and sql modules.

processing module:

1) Rename SortColumn to KeyColumn, replace boolean descending with KeyOrder.
   This makes it nicer to model hash keys, which use KeyOrder.NONE.

2) Add nullability checkers to the FieldReader interface, and an
   "isPartiallyNullKey" method to FrameComparisonWidget. The join
   processor uses this to detect null keys.

3) Add WritableFrameChannel.isClosed and OutputChannel.isReadableChannelReady
   so callers can tell which OutputChannels are ready for reading and which
   aren't.

4) Specialize FrameProcessors.makeCursor to return FrameCursor, a random-access
   implementation. The join processor uses this to rewind when it needs to
   replay a set of rows with a particular key.

5) Add MemoryAllocatorFactory, which is embedded inside FrameWriterFactory
   instead of a particular MemoryAllocator. This allows FrameWriterFactory
   to be shared in more scenarios.

multi-stage-query module:

1) ShuffleSpec: Add hash-based shuffles. New enum ShuffleKind helps callers
   figure out what kind of shuffle is happening. The change from SortColumn
   to KeyColumn allows ClusterBy to be used for both hash-based and sort-based
   shuffling.

2) WorkerImpl: Add ability to handle hash-based shuffles. Refactor the logic
   to be more readable by moving the work-order-running code to the inner
   class RunWorkOrder, and the shuffle-pipeline-building code to the inner
   class ShufflePipelineBuilder.

3) Add SortMergeJoinFrameProcessor and factory.

4) WorkerMemoryParameters: Adjust logic to reserve space for output frames
   for hash partitioning. (We need one frame per partition.)

sql module:

1) Add sqlJoinAlgorithm context parameter; can be "broadcast" or
   "sortMerge". With native, it must always be "broadcast", or it's a
   validation error. MSQ supports both. Default is "broadcast" in
   both engines.

2) Validate that MSQs do not use broadcast join with RIGHT or FULL join,
   as results are not correct for broadcast join with those types. Allow
   this in native for two reasons: legacy (the docs caution against it,
   but it's always been allowed), and the fact that it actually *does*
   generate correct results in native when the join is processed on the
   Broker. It is much less likely that MSQ will plan in such a way that
   generates correct results.

3) Remove subquery penalty in DruidJoinQueryRel when using sort-merge
   join, because subqueries are always required, so there's no reason
   to penalize them.

4) Move previously-disabled join reordering and manipulation rules to
   FANCY_JOIN_RULES, and enable them when using sort-merge join. Helps
   get to better plans where projections and filters are pushed down.

* Work around compiler problem.

* Updates from static analysis.

* Fix @param tag.

* Fix declared exception.

* Fix spelling.

* Minor adjustments.

* wip

* Merge fixups

* fixes

* Fix CalciteSelectQueryMSQTest

* Empty keys are sortable.

* Address comments from code review. Rename mux -> mix.

* Restore inspection config.

* Restore original doc.

* Reorder imports.

* Adjustments

* Fix.

* Fix imports.

* Adjustments from review.

* Update header.

* Adjust docs.
2023-03-08 14:19:39 -08:00
..
_bin De-incubation cleanup in code, docs, packaging (#9108) 2020-01-03 12:33:19 -05:00
assets Tutorial: Query view (#13565) 2023-01-27 14:29:43 -08:00
comparisons remove ref to plywood repo (#12809) 2022-07-26 10:12:13 +08:00
configuration Removes FiniteFirehoseFactory and its implementations (#12852) 2023-03-02 18:07:17 +05:30
data-management Create update.md (#13451) 2023-01-25 16:23:40 -08:00
dependencies Zero-copy local deep storage. (#13394) 2022-12-12 17:28:24 -08:00
design Various documentation updates. (#13107) 2022-09-16 21:58:11 -07:00
development Add Post Aggregators for Tuple Sketches (#13819) 2023-03-03 09:32:09 +05:30
ingestion docs: fix html nits (#13835) 2023-03-02 11:19:32 -08:00
misc Docs: update description of query priority default value (#13191) 2022-10-14 14:28:04 -07:00
multi-stage-query Sort-merge join and hash shuffles for MSQ. (#13506) 2023-03-08 14:19:39 -08:00
operations Improved error message when topic name changes within same supervisor (#13815) 2023-03-07 18:10:18 -08:00
querying Sort-merge join and hash shuffles for MSQ. (#13506) 2023-03-08 14:19:39 -08:00
tutorials Python Druid API for use in notebooks (#13787) 2023-03-04 18:25:19 -08:00