SNOW-1734385: Do not create CTE when partitioning WithQueryBlocks#2948
Merged
sfc-gh-aalam merged 4 commits intomainfrom Jan 30, 2025
Merged
Conversation
sfc-gh-yzou
reviewed
Jan 29, 2025
| def _get_partitioned_plan(self, root: TreeNode, child: TreeNode) -> SnowflakePlan: | ||
| def _extract_child_from_with_query_block( | ||
| self, child: Optional[LogicalPlan] | ||
| ) -> TreeNode: |
Collaborator
There was a problem hiding this comment.
move this to utils right below is_with_query_block function to group the functionality.
|
|
||
|
|
||
| def is_with_query_block(node: Optional[LogicalPlan]) -> bool: | ||
| if isinstance(node, WithQueryBlock): |
Collaborator
There was a problem hiding this comment.
add a comment here that this function is check whether a given logical node is a node or resolved SnowflakePlan or Selectable for WithQueryBlock
| return session._run_query("SELECT CURRENT_TRANSACTION()")[0][0] is not None | ||
|
|
||
|
|
||
| def is_with_query_block(node: Optional[LogicalPlan]) -> bool: |
Collaborator
There was a problem hiding this comment.
does the node needs to be optional? when it will be none?
Contributor
Author
There was a problem hiding this comment.
it will be none if node is a snowflakeplan and node.source_plan is None. But it can be handled within the if-else logic so I'll make it non-optional here
sfc-gh-yzou
approved these changes
Jan 30, 2025
sfc-gh-jdu
approved these changes
Jan 30, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-1734385
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
When large query breakdown partitions node such that the child node being partitioned is a
WithQueryBlock, do not create a cte. Instead, use the underlying sql to materialize it as a table.