Skip to content

Commit

Permalink
SNOW-1411701: fix regression test failure (#1636)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aling authored May 21, 2024
1 parent ec983a6 commit f9e7684
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
19 changes: 13 additions & 6 deletions tests/integ/scala/test_function_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,19 @@ def test_to_timestamp_numeric_scale_column(
],
)
def test_to_timestamp_variant_column(to_type, expected, session, local_testing_mode):
data = [
12345678900, # integer
"12345678900", # string containing integer
"2024-02-01 12:34:56.789000", # timestamp str
datetime(2017, 12, 24, 12, 55, 59, 123456), # timestamp
]

if to_type == to_timestamp_ntz and IS_IN_STORED_PROC:
# integer in variant type depends on local time zone of the server
# while in sproc reg test, the timezone is non-deterministic leading to non-deterministic result
# here we pop the case of integer in variant type
expected.pop(0)
data.pop(0)
with parameter_override(
session,
"timezone",
Expand All @@ -1842,12 +1855,6 @@ def test_to_timestamp_variant_column(to_type, expected, session, local_testing_m
# as we are testing Variant + Integer case
# this timezone has to be the same as the one in session
LocalTimezone.set_local_timezone(pytz.timezone("Etc/GMT+8"))
data = [
12345678900, # integer
"12345678900", # string containing integer
"2024-02-01 12:34:56.789000", # timestamp str
datetime(2017, 12, 24, 12, 55, 59, 123456), # timestamp
]
df = session.create_dataframe(
data,
StructType(
Expand Down
20 changes: 15 additions & 5 deletions tests/integ/test_df_to_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ def test_to_pandas_batches(session, local_testing_mode):
break


@pytest.mark.localtest
@pytest.mark.skipif(
IS_IN_STORED_PROC, reason="SNOW-1362480, backend optimization in different reg env"
)
def test_df_to_pandas_df(session):
df = session.create_dataframe(
[
Expand Down Expand Up @@ -365,15 +367,23 @@ def test_df_to_pandas_df(session):
"A": pd.Series(["[\n 1,\n 2,\n 3,\n 4\n]"], dtype=object),
"B": pd.Series([b"123"], dtype=object),
"C": pd.Series([True], dtype=bool),
"D": pd.Series([1], dtype=np.int64),
"D": pd.Series(
[1], dtype=np.int64
), # in reg env, there can be backend optimization resulting in np.int8
"E": pd.Series([datetime.date(year=2023, month=10, day=30)], dtype=object),
"F": pd.Series([decimal.Decimal(1)], dtype=np.int64),
"G": pd.Series([1.23], dtype=np.float64),
"H": pd.Series([1.23], dtype=np.float64),
"I": pd.Series([100], dtype=np.int64),
"J": pd.Series([100], dtype=np.int64),
"I": pd.Series(
[100], dtype=np.int64
), # in reg env, there can be backend optimization resulting in np.int8
"J": pd.Series(
[100], dtype=np.int64
), # in reg env, there can be backend optimization resulting in np.int8
"K": pd.Series([None], dtype=object),
"L": pd.Series([100], dtype=np.int64),
"L": pd.Series(
[100], dtype=np.int64
), # in reg env, there can be backend optimization resulting in np.int8
"M": pd.Series(["abc"], dtype=object),
"N": pd.Series(
[datetime.datetime(2023, 10, 30, 12, 12, 12)], dtype="datetime64[ns]"
Expand Down
8 changes: 6 additions & 2 deletions tests/integ/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@
StringType,
StructField,
StructType,
TimestampTimeZone,
TimestampType,
VariantType,
)
from tests.utils import TestData, Utils
Expand Down Expand Up @@ -388,13 +390,15 @@ def test_date_or_time_to_char(session, convert_func):
datetime.datetime(2021, 12, 21, 9, 12, 56),
datetime.datetime(1969, 1, 1, 1, 1, 1),
],
schema=["a"],
schema=StructType([StructField("a", TimestampType(TimestampTimeZone.NTZ))]),
)
assert df.select(convert_func(col("a"), "mm-dd-yyyy mi:ss:hh24")).collect() == [
Row("12-21-2021 12:56:09"),
Row("01-01-1969 01:01:01"),
]
assert df.select(convert_func(col("a"))).collect() == [
# we explicitly set format here because in some test env the default output format is changed
# leading to different result
assert df.select(convert_func(col("a"), "yyyy-mm-dd hh24:mi:ss.FF3")).collect() == [
Row("2021-12-21 09:12:56.000"),
Row("1969-01-01 01:01:01.000"),
]
Expand Down

0 comments on commit f9e7684

Please sign in to comment.