From e20bdad2b1fe93f45def30b4f1323e66c2faf101 Mon Sep 17 00:00:00 2001 From: Jim Crist-Harif Date: Mon, 19 Aug 2024 15:28:02 -0500 Subject: [PATCH] fix(exasol): properly handle returning BIGINT values --- ibis/backends/exasol/converter.py | 9 +++++++++ ibis/backends/tests/test_conditionals.py | 7 +------ ibis/backends/tests/test_generic.py | 2 +- ibis/backends/tests/test_join.py | 10 +--------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/ibis/backends/exasol/converter.py b/ibis/backends/exasol/converter.py index fb7e83dc712e..98768f2b13a1 100644 --- a/ibis/backends/exasol/converter.py +++ b/ibis/backends/exasol/converter.py @@ -13,6 +13,15 @@ def convert_String(cls, s, dtype, pandas_type): else: return s + @classmethod + def convert_Int64(cls, s, dtype, pandas_dtype): + if s.dtype == "object": + # exasol returns BIGINT types as strings (or None for NULL). + # s.astype("int64") will fail in this case, using `Series.map` + # is the best we can do. + return s.map(int, na_action="ignore") + return s if s.dtype == pandas_dtype else s.astype(pandas_dtype) + @classmethod def convert_Interval(cls, s, dtype, pandas_dtype): def parse_timedelta(value): diff --git a/ibis/backends/tests/test_conditionals.py b/ibis/backends/tests/test_conditionals.py index 68d6ca7c6f00..90bd76dc4441 100644 --- a/ibis/backends/tests/test_conditionals.py +++ b/ibis/backends/tests/test_conditionals.py @@ -90,11 +90,6 @@ def test_value_cases_scalar(con, inp, exp): assert result == exp -@pytest.mark.notimpl( - "exasol", - reason="the int64 RBI column is .to_pandas()ed to an object column, which is incomparable to ints", - raises=AssertionError, -) def test_value_cases_column(batting): np = pytest.importorskip("numpy") @@ -124,7 +119,7 @@ def test_ibis_cases_scalar(): @pytest.mark.notimpl( - ["sqlite", "exasol"], + ["sqlite"], reason="the int64 RBI column is .to_pandas()ed to an object column, which is incomparable to 5", raises=TypeError, ) diff --git a/ibis/backends/tests/test_generic.py b/ibis/backends/tests/test_generic.py index 73d1545bd8bf..b76ad6657068 100644 --- a/ibis/backends/tests/test_generic.py +++ b/ibis/backends/tests/test_generic.py @@ -637,7 +637,7 @@ def test_order_by_nulls(con, op, nulls_first, expected): @pytest.mark.notimpl(["druid"]) @pytest.mark.never( - ["exasol", "mysql"], + ["mysql"], raises=AssertionError, reason="someone decided a long time ago that 'A' = 'a' is true in these systems", ) diff --git a/ibis/backends/tests/test_join.py b/ibis/backends/tests/test_join.py index 272e47efac71..17bf948b1cc5 100644 --- a/ibis/backends/tests/test_join.py +++ b/ibis/backends/tests/test_join.py @@ -51,12 +51,7 @@ def check_eq(left, right, how, **kwargs): "left", param( "right", - marks=[ - pytest.mark.notimpl( - ["exasol"], raises=AssertionError, reasons="results don't match" - ), - sqlite_right_or_full_mark, - ], + marks=[sqlite_right_or_full_mark], ), param( "outer", @@ -67,9 +62,6 @@ def check_eq(left, right, how, **kwargs): pytest.mark.notimpl(["mysql"]), sqlite_right_or_full_mark, pytest.mark.xfail_version(datafusion=["datafusion<31"]), - pytest.mark.notimpl( - ["exasol"], raises=AssertionError, reasons="results don't match" - ), ], ), ],