Skip to content

fix: distribute derived tables and stop silent sort/SQL bugs - #58

Merged
renecannao merged 3 commits into
fix/shard-planner-correctnessfrom
fix/shard-derived-sort-sql
Aug 19, 2026
Merged

fix: distribute derived tables and stop silent sort/SQL bugs#58
renecannao merged 3 commits into
fix/shard-planner-correctnessfrom
fix/shard-derived-sort-sql

Conversation

@renecannao

Copy link
Copy Markdown
Collaborator

Summary

Stacked on #57.

  • FROM (SELECT …): distribute_node rewrites DERIVED_SCAN.inner_plan. Inner scans become REMOTE_SCANs.
  • remote_sql_len: uint16_tuint32_t (matches StringRef). Test uses a 70k literal.
  • MERGE_SORT keys: ORDER BY position/alias rewritten to the select-list expr in PlanBuilder. Expression keys no longer merge on column 0 — they gather and sort locally.

Validation

  • ./run_tests --gtest_brief=1: 1315 passed, 38 skipped
  • ./run_tests --gtest_filter='DistributedPlannerTest.Derived*:DistributedPlannerTest.OrderBy*:DistributedPlannerTest.RemoteSql*:PlanExecutorTest.OrderBy*'

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.
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 951ec7f1-63ad-427e-a3fd-f6d334524b73

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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
@renecannao
renecannao merged commit ec89e65 into fix/shard-planner-correctness Aug 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant