Skip to content

Conversation

@ankitsultana
Copy link
Contributor

LogicalTableScan drops traits in the copy method, and the copy method is used often during calcite planning to copy the RelNode in a type agnostic manner.

Hence introducing a new node for this.

@ankitsultana ankitsultana added multi-stage Related to the multi-stage query engine mse-physical-optimizer labels Mar 8, 2025
+ " {\n"
+ " \"id\": \"0\",\n"
+ " \"relOp\": \"LogicalTableScan\",\n"
+ " \"relOp\": \"org.apache.pinot.calcite.rel.logical.PinotLogicalTableScan\",\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are required because RelJson only converts to short names for calcite specific packages.

@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 72.00000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 63.66%. Comparing base (59551e4) to head (3a09092).
Report is 1834 commits behind head on master.

Files with missing lines Patch % Lines
.../calcite/rel/rules/PinotImplicitTableHintRule.java 0.00% 3 Missing ⚠️
...not/calcite/rel/logical/PinotLogicalTableScan.java 75.00% 1 Missing and 1 partial ⚠️
...calcite/rel/rules/PinotTableScanConverterRule.java 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #15225      +/-   ##
============================================
+ Coverage     61.75%   63.66%   +1.90%     
- Complexity      207     1461    +1254     
============================================
  Files          2436     2774     +338     
  Lines        133233   156264   +23031     
  Branches      20636    23983    +3347     
============================================
+ Hits          82274    99478   +17204     
- Misses        44911    49299    +4388     
- Partials       6048     7487    +1439     
Flag Coverage Δ
custom-integration1 100.00% <ø> (+99.99%) ⬆️
integration 100.00% <ø> (+99.99%) ⬆️
integration1 100.00% <ø> (+99.99%) ⬆️
integration2 0.00% <ø> (ø)
java-11 63.61% <72.00%> (+1.90%) ⬆️
java-21 63.52% <72.00%> (+1.90%) ⬆️
skip-bytebuffers-false 63.64% <72.00%> (+1.89%) ⬆️
skip-bytebuffers-true 63.50% <72.00%> (+35.77%) ⬆️
temurin 63.66% <72.00%> (+1.90%) ⬆️
unittests 63.65% <72.00%> (+1.90%) ⬆️
unittests1 56.17% <72.00%> (+9.28%) ⬆️
unittests2 34.20% <60.00%> (+6.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

public static PinotImplicitTableHintRule withWorkerManager(WorkerManager workerManager) {
return new PinotImplicitTableHintRule(ImmutablePinotImplicitTableHintRule.Config.builder()
.operandSupplier(b0 -> b0.operand(LogicalTableScan.class).anyInputs())
.operandSupplier(b0 -> b0.operand(PinotLogicalTableScan.class).anyInputs())
Copy link
Contributor

Choose a reason for hiding this comment

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

Given that we are changing this now, don't you think we should be using the generic TableScan here? Is there a reason we can only apply this (and other) rule to Logical tables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah using TableScan here would be better since this rule is not dependent on either Logical table scan or the new Pinot named variant. Updated.

if (tableScan instanceof LogicalTableScan) {
call.transformTo(PinotLogicalTableScan.create(call.rel(0)));
} else if (!(tableScan instanceof PinotLogicalTableScan)) {
throw new IllegalStateException("Unknown table scan in PinotTableScanConverterRule: " + tableScan.getClass());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a QueryException here instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thrown exception here would get caught in MultiStageBrokerRequestHandler which will set the QUERY_PLANNING_ERROR_CODE. I think the idea behind this approach is that the planner etc. can throw whatever exception seems right in their context (e.g. illegal state in this case), and the broker request handler will convert it to a structured form with an error code.

I don't think QueryException is used for throwing. It is mainly used for getting a ProcessingException which shows up nicely in broker response (we should ideally make the contract explicit in QueryException javadocs)

image

Copy link
Contributor

Choose a reason for hiding this comment

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

That has recently changed in #15037. Now QueryException is an actual exception. The idea is that you can throw it anywhere during query processing and that way you can define the QueryErrorCode being used. That is not 100% true because there are still some paths that haven't been updated, but it is pretty safe to think that way.

For example, here we know that the error is not related to the query but a bug in our code, so it could be marked as QueryErrorCode.INTERNAL instead of QueryErrorCode.QUERY_PLANNING.

Anyway, it is completely valid to delegate the caller's responsibility to catch the exception and set the error code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah damn saw this comment after merging. I am working on another PR.. can update this there. Thanks for sharing this. This looks like a better approach to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

On line 34, you can directly match LogicalTableScan. I don't think we need to protect it from getting a different TableScan node

@ankitsultana ankitsultana merged commit ebfa236 into apache:master Mar 13, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mse-physical-optimizer multi-stage Related to the multi-stage query engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants