From dc548c02b95d05958ed91ba77cf05d7b4ccdeb09 Mon Sep 17 00:00:00 2001 From: Sophie Tan Date: Thu, 6 Jun 2024 14:27:57 -0700 Subject: [PATCH] Add tests --- tests/mock/test_column.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/mock/test_column.py diff --git a/tests/mock/test_column.py b/tests/mock/test_column.py new file mode 100644 index 00000000000..ee9ec5c9885 --- /dev/null +++ b/tests/mock/test_column.py @@ -0,0 +1,20 @@ +# +# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. +# + +from snowflake.snowpark.functions import col, when +from snowflake.snowpark.row import Row + + +def test_casewhen_with_non_zero_row_index(session): + df = session.create_dataframe([[1, 2], [3, 4]], schema=["a", "b"]) + assert df.filter(col("a") > 1).select( + when(col("a").is_null(), 5).when(col("a") == 1, 6).otherwise(7).as_("a") + ).collect() == [Row(A=7)] + + +def test_regexp_with_non_zero_row_index(session): + df = session.create_dataframe([["1", 2], ["3", 4]], schema=["a", "b"]) + assert df.filter(col("b") > 2).select( + col("a").like("1").alias("res") + ).collect() == [Row(RES=False)]