Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yzou committed Sep 16, 2024
1 parent d2539f1 commit ebcb213
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#

from typing import AbstractSet, Optional
from typing import AbstractSet, List, Optional

from snowflake.snowpark._internal.analyzer.expression import (
Expression,
Expand Down Expand Up @@ -30,7 +30,7 @@ def __str__(self):
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.left, self.right)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.left, self.right)

@property
Expand Down
40 changes: 20 additions & 20 deletions src/snowflake/snowpark/_internal/analyzer/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ def derive_dependent_columns(

def derive_dependent_columns_with_duplication(
*expressions: "Optional[Expression]",
) -> list[str]:
) -> List[str]:
"""
Given set of expressions, derive the list of columns that the expression dependents on.
Note, the returned columns will have duplication if the column occurred more than once in
the given expression. For example, concat(col1, upper(co1), upper(col2)) will have result
[col1, col1, col2], where col1 occurred twice in the result.
"""
result: List[str] = []
result = []
for exp in expressions:
result.extend(exp.dependent_column_names_with_duplication())
return result
Expand All @@ -91,7 +91,7 @@ def dependent_column_names(self) -> Optional[AbstractSet[str]]:
# TODO: consider adding it to __init__ or use cached_property.
return COLUMN_DEPENDENCY_EMPTY

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return []

@property
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(self, expressions: List[Expression]) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self.expressions)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self.expressions)

@property
Expand All @@ -204,7 +204,7 @@ def __init__(self, columns: Expression, values: List[Expression]) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.columns, *self.values)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.columns, *self.values)

@property
Expand Down Expand Up @@ -247,7 +247,7 @@ def __str__(self):
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return {self.name}

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return [self.name]

@property
Expand All @@ -273,7 +273,7 @@ def dependent_column_names(self) -> Optional[AbstractSet[str]]:
else COLUMN_DEPENDENCY_ALL
)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return (
derive_dependent_columns_with_duplication(*self.expressions)
if self.expressions
Expand Down Expand Up @@ -323,7 +323,7 @@ def __hash__(self):
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return self._dependent_column_names

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return (
[]
if self._dependent_column_names == COLUMN_DEPENDENCY_ALL
Expand Down Expand Up @@ -423,7 +423,7 @@ def __init__(self, expr: Expression, pattern: Expression) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr, self.pattern)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr, self.pattern)

@property
Expand Down Expand Up @@ -455,7 +455,7 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr, self.pattern)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr, self.pattern)

@property
Expand All @@ -481,7 +481,7 @@ def __init__(self, expr: Expression, collation_spec: str) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr)

@property
Expand All @@ -505,7 +505,7 @@ def __init__(self, expr: Expression, field: str) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr)

@property
Expand All @@ -530,7 +530,7 @@ def __init__(self, expr: Expression, field: int) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr)

@property
Expand Down Expand Up @@ -577,7 +577,7 @@ def sql(self) -> str:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self.children)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self.children)

@property
Expand All @@ -595,7 +595,7 @@ def __init__(self, expr: Expression, order_by_cols: List[Expression]) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr, *self.order_by_cols)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr, *self.order_by_cols)

@property
Expand Down Expand Up @@ -623,7 +623,7 @@ def __init__(
self.else_value = else_value

@property
def _child_expressions(self) -> list[Expression]:
def _child_expressions(self) -> List[Expression]:
exps = []
for exp_tuple in self.branches:
exps.extend(exp_tuple)
Expand All @@ -635,7 +635,7 @@ def _child_expressions(self) -> list[Expression]:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self._child_expressions)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self._child_expressions)

@property
Expand Down Expand Up @@ -683,7 +683,7 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self.children)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self.children)

@property
Expand All @@ -701,7 +701,7 @@ def __init__(self, col: Expression, delimiter: str, is_distinct: bool) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.col)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.col)

@property
Expand All @@ -723,7 +723,7 @@ def __init__(self, exprs: List[Expression]) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self.exprs)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self.exprs)

@property
Expand Down
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/_internal/analyzer/grouping_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, group_by_exprs: List[Expression]) -> None:
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(*self.group_by_exprs)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(*self.group_by_exprs)

@property
Expand Down
4 changes: 2 additions & 2 deletions src/snowflake/snowpark/_internal/analyzer/sort_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#

from typing import AbstractSet, Optional, Type
from typing import AbstractSet, List, Optional, Type

from snowflake.snowpark._internal.analyzer.expression import (
Expression,
Expand Down Expand Up @@ -57,5 +57,5 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.child)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.child)
4 changes: 2 additions & 2 deletions src/snowflake/snowpark/_internal/analyzer/unary_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#

from typing import AbstractSet, Dict, Optional
from typing import AbstractSet, Dict, List, Optional

from snowflake.snowpark._internal.analyzer.expression import (
Expression,
Expand Down Expand Up @@ -37,7 +37,7 @@ def __str__(self):
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.child)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.child)

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.lower, self.upper)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.lower, self.upper)

@property
Expand Down Expand Up @@ -106,7 +106,7 @@ def dependent_column_names(self) -> Optional[AbstractSet[str]]:
*self.partition_spec, *self.order_spec, self.frame_spec
)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(
*self.partition_spec, *self.order_spec, self.frame_spec
)
Expand Down Expand Up @@ -147,7 +147,7 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.window_function, self.window_spec)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(
self.window_function, self.window_spec
)
Expand Down Expand Up @@ -185,7 +185,7 @@ def __init__(
def dependent_column_names(self) -> Optional[AbstractSet[str]]:
return derive_dependent_columns(self.expr, self.default)

def dependent_column_names_with_duplication(self) -> list[str]:
def dependent_column_names_with_duplication(self) -> List[str]:
return derive_dependent_columns_with_duplication(self.expr, self.default)

@property
Expand Down

0 comments on commit ebcb213

Please sign in to comment.