Skip to content

Commit

Permalink
Remove some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-stan committed Jun 5, 2024
1 parent 8b41085 commit afc8a91
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/snowflake/snowpark/mock/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ def convert_variant_to_array(val):
res = expr.apply(lambda x: try_convert(convert_variant_to_array, False, x))
else:
res = expr.apply(lambda x: try_convert(lambda y: [y], False, x))
res.sf_type = ColumnType(ArrayType(expr.sf_type.datatype), expr.sf_type.nullable)
res.sf_type = ColumnType(ArrayType(), expr.sf_type.nullable)
return res


Expand Down Expand Up @@ -1325,9 +1325,7 @@ def convert_variant_to_object(val):
f"Invalid type {type(expr.sf_type.datatype)} parameter 'TO_OBJECT'"
)

res.sf_type = ColumnType(
MapType(VariantType(), VariantType()), expr.sf_type.nullable
)
res.sf_type = ColumnType(MapType(), expr.sf_type.nullable)
return res


Expand Down Expand Up @@ -1875,5 +1873,5 @@ def mock_iff(condition: ColumnEmulator, expr1: ColumnEmulator, expr2: ColumnEmul
return res
else:
raise SnowparkLocalTestingException(
f"[Local Testing] does not support coercion currently, iff expr1 and expr2 have conflicting data types: {expr1.sf_type} != {expr2.sf_type}"
f"[Local Testing] expr1 and expr2 have conflicting datatypes that cannot be coerced: {expr1.sf_type} <-> {expr2.sf_type}"
)
2 changes: 1 addition & 1 deletion src/snowflake/snowpark/mock/_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ def calculate_expression(
& right.apply(lambda x: x is not None and np.isnan(x))
] = True # NaN == NaN evaluates to False in pandas, but True in Snowflake
new_column[new_column.isna() | new_column.isnull()] = False
# TODO: the special case with (1,2,3) == [1,2,3] should be True
# Special case when [1,2,3] == (1,2,3) should evaluate to True
index = left.combine(
right,
lambda x, y: isinstance(x, (list, tuple))
Expand Down
10 changes: 1 addition & 9 deletions tests/integ/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2372,15 +2372,7 @@ def test_replace_with_coercion(session):
[Row(1, None, "1.0"), Row(2, 2.0, "2.0")],
)

df = session.create_dataframe(
[[[1, 2], (1, 3)]],
schema=StructType(
[
StructField("col1", ArrayType(IntegerType())),
StructField("col2", ArrayType(IntegerType())),
]
),
) # schema=["col1", "col2"])
df = session.create_dataframe([[[1, 2], (1, 3)]], schema=["col1", "col2"])
Utils.check_answer(
df.replace([(1, 3)], [[2, 3]]),
[Row("[\n 1,\n 2\n]", "[\n 2,\n 3\n]")],
Expand Down
5 changes: 2 additions & 3 deletions tests/integ/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@
DecimalType,
DoubleType,
FloatType,
LongType,
MapType,
StringType,
StructField,
Expand Down Expand Up @@ -1260,9 +1259,9 @@ def test_to_date_to_array_to_variant_to_object(session, local_testing_mode):
Utils.assert_rows(res1, expected)

assert df1.schema.fields[0].datatype == DateType()
assert df1.schema.fields[1].datatype == ArrayType(LongType())
assert df1.schema.fields[1].datatype == ArrayType(StringType())
assert df1.schema.fields[2].datatype == VariantType()
assert df1.schema.fields[3].datatype == MapType(VariantType(), VariantType())
assert df1.schema.fields[3].datatype == MapType(StringType(), StringType())


@pytest.mark.localtest
Expand Down

0 comments on commit afc8a91

Please sign in to comment.