fix: stop silent wrong answers in distributed planner - #57
Merged
Conversation
COUNT(DISTINCT) and unknown aggs no longer merge as SUM_OF_COUNTS. They gather rows and aggregate locally, with DISTINCT honored in AggregateOperator. GROUP BY keeps HAVING and ORDER BY. WINDOW is distributed as gather-then-window so ORDER BY cannot drop it. Adds mock coverage plus a live 2-shard INSERT-then-point-SELECT gtest (skips without 13306/13307) and a sqlengine sharded INSERT check.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Rewrite DERIVED_SCAN inner plans so FROM (SELECT ...) hits remote shards. Store remote_sql_len as uint32_t so statements longer than 64KB are not truncated. Resolve ORDER BY position/alias in the plan builder, and only MERGE_SORT when every key is a table column — expressions gather and sort locally instead of comparing column 0.
Refuse multi-table UPDATE/DELETE when any table is sharded or backends differ. Evaluate HAVING against aggregate output so COUNT(*) filters work locally and distributed. Push equi-joins of same-layout sharded tables to each shard. sqlengine and mysql_server use 2PC when backends are configured; SELECTs inside an open distributed txn hit pinned sessions. Optional --txn-log on sqlengine.
fix: close remaining sharding correctness holes
fix: distribute derived tables and stop silent sort/SQL bugs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #56.
SUM_OF_COUNTS/SUM_OF_SUMS. Gather rows and aggregate locally. Parser recordsFLAG_FUNC_DISTINCT;AggregateOperatorhonors it.MERGE_AGGREGATE(previously dropped when ORDER BY was present).ORDER BY/LIMITno longer replace aWINDOWnode withMERGE_SORT.LiveShardedWriteTest.InsertThenPointSelect(skips unless MySQL is on 13306+13307).test_sqlengine.sh shardedINSERTs id=11 then point-SELECTs it.Validation
./run_tests --gtest_brief=1: 1309 passed, 38 skipped, 0 failed./run_tests --gtest_filter='DistributedPlannerTest.CountDistinct*:DistributedPlannerTest.GroupBy*:DistributedPlannerTest.Window*:PlanExecutorTest.CountDistinctDept'