Skip to content

SQL: Defer context-based decisions to rule runtime.#18097

Closed
gianm wants to merge 1 commit intoapache:masterfrom
gianm:fix-set-acd-false
Closed

SQL: Defer context-based decisions to rule runtime.#18097
gianm wants to merge 1 commit intoapache:masterfrom
gianm:fix-set-acd-false

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Jun 8, 2025

SET statements (#17894) provide a new way to set query context. However, they are not available at the time that the planner is constructed, which means they are not available when rules are built. Certain rules are built based on the context, which means SET was unable to affect them.

This patch fixes the problem by deferring context-based decisions from rule creation time to rule runtime.

SET statements (apache#17894) provide a new way to set query context. However,
they are not available at the time that the planner is constructed, which
means they are not available when rules are built. Certain rules are built
based on the context, which means SET was unable to affect them.

This patch fixes the problem by deferring context-based decisions from
rule creation time to rule runtime.

public DeferredProjectMergeRule(PlannerContext plannerContext)
{
super(operand(Project.class, operand(Project.class, any())));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
RelOptRule.operand
should be avoided because it has been deprecated.

public DeferredProjectMergeRule(PlannerContext plannerContext)
{
super(operand(Project.class, operand(Project.class, any())));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
RelOptRule.operand
should be avoided because it has been deprecated.

public DeferredProjectMergeRule(PlannerContext plannerContext)
{
super(operand(Project.class, operand(Project.class, any())));

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
RelOptRule.any
should be avoided because it has been deprecated.
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Jun 8, 2025

On further reflection I think this is still a not-ideal approach. It would be better to parse the SQL immediately as soon as we get the request, so even properties like engine and executionMode could be respected. I will close this since if we do parse the SQL immediately, then this deferral of contextual rule setup isn't needed.

@gianm gianm closed this Jun 8, 2025
@gianm gianm deleted the fix-set-acd-false branch June 8, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants