Skip to content

Fix testApplyTableScanRedirectionWithFilter's TableScan#7228

Merged
findepi merged 1 commit intotrinodb:masterfrom
findepi:findepi/remove-invalid-table-scan-redirection-test-case-b8868b
Mar 16, 2021
Merged

Fix testApplyTableScanRedirectionWithFilter's TableScan#7228
findepi merged 1 commit intotrinodb:masterfrom
findepi:findepi/remove-invalid-table-scan-redirection-test-case-b8868b

Conversation

@findepi
Copy link
Copy Markdown
Member

@findepi findepi commented Mar 9, 2021

Extracted from #6963

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test was meant to simulate the following scenario:
There are 2 columns A and B, there is a predicate on A and projection on B
Constraint on column A is pushed into TS and enforced by connector
Column A assignment is pruned from TS by column pruning rule

Maybe instead of removing, the test case can be fixed by passing TupleDomain.all in enforcedConstraint (or whatever is left in enforcedConstraint after PPD when a constraint is enforced by connector and engine does not need to do any extra work). I think we are correctly sending constraint into MockConnectorTableHandle to mimc PPD.

Copy link
Copy Markdown
Member

@sopel39 sopel39 Mar 9, 2021

Choose a reason for hiding this comment

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

@raunaqmorarka is the described test scenario covered by some test in TestTableScanRedirectionWithPushdown?

What do we specifically test here? After @findepi changes:

Constraint on column A is pushed into TS and enforced by connector
Column A assignment is pruned from TS by column pruning rule

won't preseve predicate on A in enforced constraint

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TestTableScanRedirectionWithPushdown#testRedirectAfterColumnPruningOnPushedDownPredicate is also about this scenario. However, there we are testing the end result of applying multiple rules. We are not explicitly verifying the result of just running the redirection rule in this scenario elsewhere.
We are preserving predicate on A in the mock table handle. I'm assuming this is sufficient to mimic the PPD part of the above scenario and that the TupleDomain in enforced constraint doesn't need to have predicate on A.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change:
Replace constraint with TupleDomain.all() in 4th parameter to p.tableScan

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From unit test perspective, this will be equivalent to unfiltered case, covered by io.trino.sql.planner.iterative.rule.TestApplyTableScanRedirection#testApplyTableScanRedirection.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It wouldn't be equivalent to unfiltered case because the constraint would still be passed to MockConnectorTableHandle and the test will continue to match for a filter node.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@raunaqmorarka right, thanks, fixed.

@findepi findepi force-pushed the findepi/remove-invalid-table-scan-redirection-test-case-b8868b branch from f39bc4e to 2e5d23f Compare March 12, 2021 12:45
@cla-bot cla-bot bot added the cla-signed label Mar 12, 2021
@findepi
Copy link
Copy Markdown
Member Author

findepi commented Mar 12, 2021

@sopel39 @raunaqmorarka
does #7228 (comment) answer the concern?

@findepi findepi force-pushed the findepi/remove-invalid-table-scan-redirection-test-case-b8868b branch from 2e5d23f to ff47dad Compare March 15, 2021 21:33
@findepi findepi changed the title Remove invalid table scan redirection test case Fix testApplyTableScanRedirectionWithFilter's TableScan Mar 15, 2021
@findepi findepi force-pushed the findepi/remove-invalid-table-scan-redirection-test-case-b8868b branch from ff47dad to 7d12a48 Compare March 15, 2021 21:34
@findepi
Copy link
Copy Markdown
Member Author

findepi commented Mar 15, 2021

rebased to resolve conflict.

The test was constructing `TableScan` with a `Domain` on a non-projected
column, but such columns should be removed from the plan together with
associated constraints. The test input is fixed to adhere to this.
@findepi findepi force-pushed the findepi/remove-invalid-table-scan-redirection-test-case-b8868b branch from 7d12a48 to 5e8f7b6 Compare March 15, 2021 21:35
@findepi findepi merged commit a5dc971 into trinodb:master Mar 16, 2021
@findepi findepi deleted the findepi/remove-invalid-table-scan-redirection-test-case-b8868b branch March 16, 2021 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants