-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1541091: Add plan compiler component (#1946)
- Loading branch information
1 parent
dc16701
commit e14b78b
Showing
4 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# |
28 changes: 28 additions & 0 deletions
28
src/snowflake/snowpark/_internal/compiler/plan_compiler.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
|
||
from typing import Dict, List | ||
|
||
from snowflake.snowpark._internal.analyzer.snowflake_plan import ( | ||
PlanQueryType, | ||
Query, | ||
SnowflakePlan, | ||
) | ||
|
||
|
||
class PlanCompiler: | ||
"""This class is common point of entry from compiling SnowflakePlan to list of queries and post actions. | ||
We run pre-check and pre-process steps for optimization steps, and apply the activated optimizations. | ||
""" | ||
|
||
def __init__(self, plan: SnowflakePlan) -> None: | ||
self._plan = plan | ||
|
||
def compile(self) -> Dict[PlanQueryType, List[Query]]: | ||
# apply optimizations | ||
final_plan = self._plan.replace_repeated_subquery_with_cte() | ||
return { | ||
PlanQueryType.QUERIES: final_plan.queries, | ||
PlanQueryType.POST_ACTIONS: final_plan.post_actions, | ||
} |