Skip to content

[Feature] Add Lance connector optimizer operators and rules#74660

Open
beinan wants to merge 3 commits into
StarRocks:mainfrom
beinan:lance/pr2-fe-optimizer
Open

[Feature] Add Lance connector optimizer operators and rules#74660
beinan wants to merge 3 commits into
StarRocks:mainfrom
beinan:lance/pr2-fe-optimizer

Conversation

@beinan

@beinan beinan commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing this

The Lance connector needs FE optimizer support so that SELECT queries against
Lance tables can be planned and optimized through the standard StarRocks
cost-based optimizer pipeline.

What I'm doing

Add the optimizer-layer plumbing for Lance, following the same pattern as the
existing Kudu connector:

  • Operator types: LOGICAL_LANCE_SCAN and PHYSICAL_LANCE_SCAN in OperatorType
  • Operators: LogicalLanceScanOperator and PhysicalLanceScanOperator
  • Visitor hooks: visitLogicalLanceScan / visitPhysicalLanceScan in
    OperatorVisitor and OptExpressionVisitor
  • Implementation rule: LanceScanImplementationRule + IMP_LANCE_LSCAN_TO_PSCAN
    in RuleType
  • Rule wiring: Registered in RuleSet implementation rules list
  • Predicate pushdown: LOGICAL_LANCE_SCAN added to PushDownPredicateScanRule
  • Statistics: StatisticsCalculator computes stats via MetadataMgr
  • Plan printer: LogicalPlanPrinter prints "LANCE SCAN"
  • Relation transformer: RelationTransformer creates LogicalLanceScanOperator
    for LANCE table type

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • This pr needs user documentation (for new or modified features or behaviors)

Related Issue

Fixes #74665

@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78e577bb81

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +738 to +740
} else if (Table.TableType.LANCE.equals(node.getTable().getType())) {
scanOperator = new LogicalLanceScanOperator(node.getTable(), colRefToColumnMetaMapBuilder.build(),
columnMetaToColRefMap, Operator.DEFAULT_LIMIT, null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Enable Lance tables before adding scan planning

This new Lance branch is unreachable for normal SQL queries because QueryAnalyzer only passes a TableRelation through when table.isSupported() is true, and LanceTable.isSupported() currently returns false; a SELECT from any Lance connector table is still rejected as Unsupported scan table type: LANCE before RelationTransformer can create this operator. The feature's optimizer plumbing therefore does not make Lance scans plannable unless the Lance table support gate is updated as part of the same change.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive: LanceTable.isSupported() is changed to true in PR #74661 which is part of this series. See #74665 for the full dependency chain.

Comment on lines +49 to +50
public <R, C> R accept(OptExpressionVisitor<R, C> visitor, OptExpression optExpression, C context) {
return visitor.visitPhysicalLanceScan(optExpression, context);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add a plan-fragment translator for Lance scans

Once a Lance scan reaches physical planning, this dispatch has no corresponding visitPhysicalLanceScan override in PlanFragmentBuilder.PhysicalPlanTranslator (unlike Kudu/Hive/Paimon/etc.). The base visitor routes visitPhysicalLanceScan to visitPhysicalScan, which calls the translator's overridden visit(...) and re-enters this accept(...) method, so any planned Lance scan recurses until a stack overflow instead of producing a ScanNode.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive: PlanFragmentBuilder.visitPhysicalLanceScan is added in PR #74661 which depends on this PR. See #74665 for the full dependency chain.

@beinan

beinan commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions run-checks

@beinan beinan force-pushed the lance/pr2-fe-optimizer branch from e8767ae to 601ce03 Compare June 16, 2026 21:01
Add the FE optimizer plumbing for the Lance connector:

- LogicalLanceScanOperator / PhysicalLanceScanOperator with visitor hooks
- LOGICAL_LANCE_SCAN / PHYSICAL_LANCE_SCAN enum entries in OperatorType
- LanceScanImplementationRule + IMP_LANCE_LSCAN_TO_PSCAN rule type
- Wire into RuleSet, PushDownPredicateScanRule, StatisticsCalculator,
  LogicalPlanPrinter, and RelationTransformer

This follows the same pattern used by the Kudu connector.

Signed-off-by: Beinan Wang <soros.wang@yahoo.com>
Co-Authored-By: Beinan Wang <beinanwang@microsoft.com>
Signed-off-by: Beinan Wang <soros.wang@yahoo.com>
@beinan beinan force-pushed the lance/pr2-fe-optimizer branch from 601ce03 to 7de25df Compare June 24, 2026 20:46
@beinan

beinan commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions run-checks

1 similar comment
@beinan

beinan commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions run-checks

Signed-off-by: Beinan Wang <soros.wang@yahoo.com>
@beinan

beinan commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi @stephen-shelby @HangyuanLiu, gentle ping on this PR when you have a chance. It is the first (bottom) PR of the Lance connector stack (#74660#74661#74662#74663#74664) and only adds the optimizer operators/rules. CI is green except for a known flaky PublishVersionDaemonTest.testSharedNothingPublishWithThreadPool (unrelated to this change), which I have just re-triggered. Would appreciate your review to get the stack moving. Thanks!

Cover LogicalLanceScanOperator, PhysicalLanceScanOperator, and
LanceScanImplementationRule to satisfy FE incremental coverage.

Signed-off-by: Beinan Wang <soros.wang@yahoo.com>
Co-Authored-By: Beinan Wang <beinanwang@microsoft.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 45 / 54 (83.33%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/sql/optimizer/statistics/StatisticsCalculator.java 0 8 00.00% [814, 819, 824, 825, 826, 828, 829, 832]
🔵 com/starrocks/sql/optimizer/transformer/RelationTransformer.java 1 2 50.00% [739]
🔵 com/starrocks/sql/optimizer/operator/physical/PhysicalLanceScanOperator.java 14 14 100.00% []
🔵 com/starrocks/sql/optimizer/rule/implementation/LanceScanImplementationRule.java 7 7 100.00% []
🔵 com/starrocks/sql/optimizer/operator/OperatorVisitor.java 2 2 100.00% []
🔵 com/starrocks/sql/optimizer/rule/RuleType.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/LogicalPlanPrinter.java 1 1 100.00% []
🔵 com/starrocks/sql/optimizer/operator/OperatorType.java 2 2 100.00% []
🔵 com/starrocks/sql/optimizer/operator/logical/LogicalLanceScanOperator.java 16 16 100.00% []
🔵 com/starrocks/sql/optimizer/OptExpressionVisitor.java 1 1 100.00% []

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

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.

[Feature] Native Lance connector for StarRocks

2 participants