Skip to content

Commit 5d3540e

Browse files
authored
NO-SNOW: fix dbpi tests (#3399)
1 parent b40e4e1 commit 5d3540e

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

.github/workflows/daily_precommit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ jobs:
154154
TOX_PARALLEL_NO_SPINNER: 1
155155
shell: bash
156156
- name: Run data source tests
157+
# psycopg2 is not supported on macos 3.9
158+
if: ${{ !(matrix.os == 'macos-latest' && matrix.python-version == '3.9') }}
157159
run: python -m tox -e datasource
158160
env:
159161
PYTHON_VERSION: ${{ matrix.python-version }}

tests/integ/datasource/test_databricks.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
TEST_TABLE_NAME,
3434
DATABRICKS_TEST_EXTERNAL_ACCESS_INTEGRATION,
3535
)
36-
from tests.utils import IS_IN_STORED_PROC
36+
from tests.utils import IS_IN_STORED_PROC, Utils
3737

3838
DEPENDENCIES_PACKAGE_UNAVAILABLE = True
3939
try:
@@ -65,15 +65,16 @@ def test_basic_databricks(session, input_type, input_value):
6565
input_type: input_value,
6666
}
6767
df = session.read.dbapi(create_databricks_connection, **input_dict).order_by(
68-
"COL_BYTE"
68+
"COL_BYTE", ascending=True
6969
)
70-
ret = df.collect()
71-
assert ret == EXPECTED_TEST_DATA and df.schema == EXPECTED_TYPE
70+
Utils.check_answer(df, EXPECTED_TEST_DATA)
71+
assert df.schema == EXPECTED_TYPE
7272

7373
table_name = random_name_for_temp_object(TempObjectType.TABLE)
7474
df.write.save_as_table(table_name, mode="overwrite", table_type="temp")
75-
df2 = session.table(table_name).order_by("COL_BYTE")
76-
assert df2.collect() == EXPECTED_TEST_DATA and df2.schema == EXPECTED_TYPE
75+
df2 = session.table(table_name).order_by("COL_BYTE", ascending=True)
76+
Utils.check_answer(df2, EXPECTED_TEST_DATA)
77+
assert df2.schema == EXPECTED_TYPE
7778

7879

7980
@pytest.mark.parametrize(
@@ -146,9 +147,9 @@ def local_create_databricks_connection():
146147
udtf_configs={
147148
"external_access_integration": DATABRICKS_TEST_EXTERNAL_ACCESS_INTEGRATION
148149
},
149-
).order_by("COL_BYTE")
150-
ret = df.collect()
151-
assert ret == EXPECTED_TEST_DATA and df.schema == EXPECTED_TYPE
150+
).order_by("COL_BYTE", ascending=True)
151+
Utils.check_answer(df, EXPECTED_TEST_DATA)
152+
assert df.schema == EXPECTED_TYPE
152153

153154
assert (
154155
"TEMPORARY FUNCTION data_source_udtf_" "" in caplog.text

tests/resources/test_data_source_dir/test_databricks_data.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
VariantType,
2323
)
2424

25-
TEST_TABLE_NAME = "ALL_TYPE_TABLE_2" # ALL_TYPE_TABLE_2 contains None data while ALL_TYPE_TABLE doesn't
25+
TEST_TABLE_NAME = "ALL_TYPE_TABLE_3" # ALL_TYPE_TABLE_3 contains None data while ALL_TYPE_TABLE doesn't
2626
TZ_INFO = pytz.timezone("America/Los_Angeles")
2727
EXPECTED_TEST_DATA = [
2828
tuple([None] * 18),
@@ -44,7 +44,7 @@
4444
datetime.datetime(2025, 4, 16, 17, 51, 18, 565000),
4545
"[\n 6,\n 87\n]",
4646
'{\n "key1": 83,\n "key2": 12\n}',
47-
'{\n "field1": "f_77",\n "field2": 13\n}',
47+
'{\n "field1": "f_77",\n "field2": "13"\n}',
4848
"1-8",
4949
"0 23:14:09.000000000",
5050
),
@@ -66,7 +66,7 @@
6666
datetime.datetime(2025, 4, 16, 17, 42, 39, 565000),
6767
"[\n 0,\n 89\n]",
6868
'{\n "key1": 97,\n "key2": 33\n}',
69-
'{\n "field1": "f_84",\n "field2": 1\n}',
69+
'{\n "field1": "f_84",\n "field2": "1"\n}',
7070
"1-10",
7171
"2 11:12:05.000000000",
7272
),
@@ -88,7 +88,7 @@
8888
datetime.datetime(2025, 4, 16, 17, 49, 8, 565000),
8989
"[\n 82,\n 40\n]",
9090
'{\n "key1": 71,\n "key2": 81\n}',
91-
'{\n "field1": "f_25",\n "field2": 25\n}',
91+
'{\n "field1": "f_25",\n "field2": "25"\n}',
9292
"3-10",
9393
"18 14:29:08.000000000",
9494
),
@@ -110,7 +110,7 @@
110110
datetime.datetime(2025, 4, 16, 17, 47, 9, 565000),
111111
"[\n 81,\n 65\n]",
112112
'{\n "key1": 67,\n "key2": 88\n}',
113-
'{\n "field1": "f_98",\n "field2": 69\n}',
113+
'{\n "field1": "f_98",\n "field2": "69"\n}',
114114
"0-7",
115115
"19 06:25:08.000000000",
116116
),
@@ -132,7 +132,7 @@
132132
datetime.datetime(2025, 4, 16, 17, 50, 8, 565000),
133133
"[\n 92,\n 27\n]",
134134
'{\n "key1": 52,\n "key2": 65\n}',
135-
'{\n "field1": "f_85",\n "field2": 50\n}',
135+
'{\n "field1": "f_85",\n "field2": "50"\n}',
136136
"7-4",
137137
"22 04:52:41.000000000",
138138
),

0 commit comments

Comments
 (0)