Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit f23e5f5

Browse files
authored
test: fix unit tests for ibis 3.0 naming changes (#131)
* test: fix unit tests for ibis 3.0 naming changes * fix tests for ibis 2 * test with 3.0.2 * fix for 2.0.0 * add expected regression to system tests
1 parent 0d8d6dc commit f23e5f5

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ jobs:
5959
- python_version: "3.8"
6060
"ibis_version": "2.1.1"
6161
- python_version: "3.9"
62-
"ibis_version": "3.0.0"
62+
"ibis_version": "3.0.2"
6363
- python_version: "3.10"
64-
"ibis_version": "3.0.0"
64+
"ibis_version": "3.0.2"
6565
- python_version: "3.10"
6666
"ibis_version": "github"
6767

.github/workflows/system-tests-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
- python_version: "3.8"
2424
"ibis_version": "2.1.1"
2525
- python_version: "3.9"
26-
"ibis_version": "3.0.0"
26+
"ibis_version": "3.0.2"
2727
- python_version: "3.10"
28-
"ibis_version": "3.0.0"
28+
"ibis_version": "3.0.2"
2929
- python_version: "3.10"
3030
"ibis_version": "github"
3131

.github/workflows/system-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
- python_version: "3.8"
2222
"ibis_version": "2.1.1"
2323
- python_version: "3.9"
24-
"ibis_version": "3.0.0"
24+
"ibis_version": "3.0.2"
2525
- python_version: "3.10"
26-
"ibis_version": "3.0.0"
26+
"ibis_version": "3.0.2"
2727
- python_version: "3.10"
2828
"ibis_version": "github"
2929

tests/system/test_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
IBIS_VERSION = packaging.version.Version(ibis.__version__)
1919
IBIS_1_4_VERSION = packaging.version.Version("1.4.0")
20+
IBIS_3_0_VERSION = packaging.version.Version("3.0.0")
2021

2122

2223
def test_table(alltypes):
@@ -84,7 +85,8 @@ def test_compile_toplevel():
8485
def test_struct_field_access(struct_table):
8586
expr = struct_table.struct_col["string_field"]
8687
result = expr.execute()
87-
expected = pd.Series([None, "a"], name="tmp")
88+
expected_name = "tmp" if IBIS_VERSION < IBIS_3_0_VERSION else "string_field"
89+
expected = pd.Series([None, "a"], name=expected_name)
8890
tm.assert_series_equal(result, expected)
8991

9092

tests/unit/test_compiler.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
IBIS_VERSION = packaging.version.Version(ibis.__version__)
1414
IBIS_1_4_VERSION = packaging.version.Version("1.4.0")
15+
IBIS_3_0_VERSION = packaging.version.Version("3.0.0")
1516

1617

1718
@pytest.mark.parametrize(
@@ -313,8 +314,9 @@ def test_binary():
313314
t = ibis.table([("value", "double")], name="t")
314315
expr = t["value"].cast(dt.binary).name("value_hash")
315316
result = ibis_bigquery.compile(expr)
316-
expected = """\
317-
SELECT CAST(`value` AS BYTES) AS `tmp`
317+
expected_name = "tmp" if IBIS_VERSION < IBIS_3_0_VERSION else "value_hash"
318+
expected = f"""\
319+
SELECT CAST(`value` AS BYTES) AS `{expected_name}`
318320
FROM t"""
319321
assert result == expected
320322

@@ -345,21 +347,22 @@ def test_bucket():
345347
buckets = [0, 1, 3]
346348
expr = t.value.bucket(buckets).name("foo")
347349
result = ibis_bigquery.compile(expr)
348-
expected = """\
350+
expected_name = "tmp" if IBIS_VERSION < IBIS_3_0_VERSION else "foo"
351+
expected = f"""\
349352
SELECT
350353
CASE
351354
WHEN (0 <= `value`) AND (`value` < 1) THEN 0
352355
WHEN (1 <= `value`) AND (`value` <= 3) THEN 1
353356
ELSE CAST(NULL AS INT64)
354-
END AS `tmp`
357+
END AS `{expected_name}`
355358
FROM t"""
356-
expected_2 = """\
359+
expected_2 = f"""\
357360
SELECT
358361
CASE
359362
WHEN (`value` >= 0) AND (`value` < 1) THEN 0
360363
WHEN (`value` >= 1) AND (`value` <= 3) THEN 1
361364
ELSE CAST(NULL AS INT64)
362-
END AS `tmp`
365+
END AS `{expected_name}`
363366
FROM t"""
364367
assert result == expected or result == expected_2
365368

@@ -376,10 +379,11 @@ def test_window_unbounded(kind, begin, end, expected):
376379
kwargs = {kind: (begin, end)}
377380
expr = t.a.sum().over(ibis.window(**kwargs))
378381
result = ibis_bigquery.compile(expr)
382+
expected_name = "tmp" if IBIS_VERSION < IBIS_3_0_VERSION else "sum"
379383
assert (
380384
result
381385
== f"""\
382-
SELECT sum(`a`) OVER (ROWS BETWEEN {expected}) AS `tmp`
386+
SELECT sum(`a`) OVER (ROWS BETWEEN {expected}) AS `{expected_name}`
383387
FROM t"""
384388
)
385389

0 commit comments

Comments
 (0)