Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1645316: Modularize skip lqb conditions and add no db check #2451

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sfc-gh-aalam
Copy link
Contributor

@sfc-gh-aalam sfc-gh-aalam commented Oct 14, 2024

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1645316

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
  3. Please describe how your code solves the related issue.

    i) Move skip large query breakdown into two functions:

    • _should_skip_optimization_for_session
    • _should_skip_optimization_for_root

    ii) Add a condition to skip large query breakdown when no database exists

@sfc-gh-aalam sfc-gh-aalam added the NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md label Oct 14, 2024
@sfc-gh-aalam sfc-gh-aalam marked this pull request as ready for review October 17, 2024 18:22
@sfc-gh-aalam sfc-gh-aalam requested a review from a team as a code owner October 17, 2024 18:22
self,
) -> Optional[SkipLargeQueryBreakdownCategory]:
"""Method to check if the optimization should be skipped based on the session state."""
if self.session.get_current_database() is None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

how about schema? when there no current schema, that won't work also

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to see if it is possible to get no schema. Snowflake automatically picks PUBLIC so I could create a scenario where there is no schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a check anyways.

@@ -123,14 +123,14 @@ def __init__(
self.complexity_score_upper_bound = complexity_bounds[1]

def apply(self) -> List[LogicalPlan]:
if is_active_transaction(self.session):
if reason := self._should_skip_optimization_for_session():
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's just do

reason = self._should_skip_optimization_for_session()
if reason is not None:
    xxx

easier for me to understand

def _should_skip_optimization_for_session(
self,
) -> Optional[SkipLargeQueryBreakdownCategory]:
"""Method to check if the optimization should be skipped based on the session state."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

add comment about the return value

@sfc-gh-aalam sfc-gh-aalam enabled auto-merge (squash) October 22, 2024 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants