Skip to content

Commit 01e5968

Browse files
Merge branch 'vbudati/SNOW-1794510-merge-decoder' into vbudati/SNOW-1830540-decoder-union-table-functions
2 parents 0f49892 + 2622b00 commit 01e5968

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/snowflake/snowpark/_internal/proto/ast.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ message List_SpDataType {
2222
repeated SpDataType list = 1;
2323
}
2424

25+
message List_SpStructField {
26+
repeated SpStructField list = 1;
27+
}
28+
2529
message List_String {
2630
repeated string list = 1;
2731
}
@@ -174,7 +178,7 @@ message SpStructField {
174178

175179
// sp-type.ir:46
176180
message SpStructType {
177-
repeated SpStructField fields = 1;
181+
List_SpStructField fields = 1;
178182
bool structured = 2;
179183
}
180184

tests/ast/decoder.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
# Copyright (c) 2012-2025 Snowflake Computing Inc. All rights reserved.
33
#
44

5-
#
6-
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
7-
#
8-
95
import logging
106
import re
117
from typing import Any, Optional, Iterable, List, Union, Dict, Tuple, Callable
@@ -16,11 +12,10 @@
1612

1713
from google.protobuf.json_format import MessageToDict
1814

19-
from build.lib.snowflake.snowpark.functions import call_table_function
20-
from build.lib.snowflake.snowpark.relational_grouped_dataframe import GroupingSets
15+
from snowflake.snowpark.relational_grouped_dataframe import GroupingSets
2116
from snowflake.snowpark import Session, Column, DataFrameAnalyticsFunctions
2217
import snowflake.snowpark.functions
23-
from snowflake.snowpark.functions import udf, when, sproc
18+
from snowflake.snowpark.functions import udf, when, sproc, call_table_function
2419
from snowflake.snowpark.types import (
2520
DataType,
2621
ArrayType,
@@ -718,6 +713,9 @@ def decode_expr(self, expr: proto.Expr, **kwargs) -> Any:
718713
for kv in expr.seq_map_val.kvs
719714
}
720715

716+
case "sp_datatype_val":
717+
return self.decode_data_type_expr(expr.sp_datatype_val.datatype)
718+
721719
case "tuple_val":
722720
# vs can be a list of Expr, a single Expr, or ().
723721
if hasattr(expr.tuple_val, "vs"):
@@ -845,7 +843,13 @@ def decode_expr(self, expr: proto.Expr, **kwargs) -> Any:
845843
return col.is_null()
846844

847845
case "sp_column_sql_expr":
848-
return expr.sp_column_sql_expr.sql
846+
sql_expr = expr.sp_column_sql_expr.sql
847+
# Need to explicitly specify col("*") because of the way sql_expr AST is encoded.
848+
return (
849+
snowflake.snowpark.functions.col(sql_expr)
850+
if sql_expr == "*"
851+
else sql_expr
852+
)
849853

850854
case "sp_column_string_like":
851855
col = self.decode_expr(expr.sp_column_string_like.col)

0 commit comments

Comments
 (0)