Skip to content

Commit 2622b00

Browse files
SNOW-1830541 Decoder functionality for functions1.test and functions2.test (#2881)
1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR. Fixes SNOW-1830541 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. - [x] I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: [Thread-safe Developer Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#thread-safe-development) 3. Please describe how your code solves the related issue. Minor changes to the decoder to make functions1.test and functions2.test work.
1 parent 49b5e29 commit 2622b00

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
2+
# Copyright (c) 2012-2025 Snowflake Computing Inc. All rights reserved.
33
#
44

55
import logging
@@ -12,7 +12,7 @@
1212

1313
from google.protobuf.json_format import MessageToDict
1414

15-
from build.lib.snowflake.snowpark.relational_grouped_dataframe import GroupingSets
15+
from snowflake.snowpark.relational_grouped_dataframe import GroupingSets
1616
from snowflake.snowpark import Session, Column, DataFrameAnalyticsFunctions
1717
import snowflake.snowpark.functions
1818
from snowflake.snowpark.functions import udf, when, sproc
@@ -676,6 +676,9 @@ def decode_expr(self, expr: proto.Expr) -> Any:
676676
for kv in expr.seq_map_val.kvs
677677
}
678678

679+
case "sp_datatype_val":
680+
return self.decode_data_type_expr(expr.sp_datatype_val.datatype)
681+
679682
case "tuple_val":
680683
# vs can be a list of Expr, a single Expr, or ().
681684
if hasattr(expr.tuple_val, "vs"):
@@ -803,7 +806,13 @@ def decode_expr(self, expr: proto.Expr) -> Any:
803806
return col.is_null()
804807

805808
case "sp_column_sql_expr":
806-
return expr.sp_column_sql_expr.sql
809+
sql_expr = expr.sp_column_sql_expr.sql
810+
# Need to explicitly specify col("*") because of the way sql_expr AST is encoded.
811+
return (
812+
snowflake.snowpark.functions.col(sql_expr)
813+
if sql_expr == "*"
814+
else sql_expr
815+
)
807816

808817
case "sp_column_string_like":
809818
col = self.decode_expr(expr.sp_column_string_like.col)

0 commit comments

Comments
 (0)