Skip to content

Commit

Permalink
test(decimal): add xfailing test constructing memtable decimal column…
Browse files Browse the repository at this point in the history
…s with integers
  • Loading branch information
cpcloud committed Nov 14, 2024
1 parent 564594f commit 7ac1487
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ibis/backends/tests/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
ArithmeticException as PySparkArithmeticException,
)
from pyspark.errors.exceptions.base import ParseException as PySparkParseException
from pyspark.errors.exceptions.base import PySparkValueError
from pyspark.errors.exceptions.base import PythonException as PySparkPythonException
from pyspark.errors.exceptions.connect import (
SparkConnectGrpcException as PySparkConnectGrpcException,
)
except ImportError:
PySparkParseException = PySparkAnalysisException = PySparkArithmeticException = (
PySparkPythonException
) = PySparkConnectGrpcException = None
) = PySparkConnectGrpcException = PySparkValueError = None

try:
from google.api_core.exceptions import BadRequest as GoogleBadRequest
Expand Down
47 changes: 47 additions & 0 deletions ibis/backends/tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import decimal
import math
import operator
import sqlite3
from operator import and_, lshift, or_, rshift, xor

import pytest
Expand All @@ -30,13 +31,15 @@
PyODBCProgrammingError,
PySparkArithmeticException,
PySparkParseException,
PySparkValueError,
SnowflakeProgrammingError,
TrinoUserError,
)
from ibis.expr import datatypes as dt

np = pytest.importorskip("numpy")
pd = pytest.importorskip("pandas")
pa = pytest.importorskip("pyarrow")


@pytest.mark.parametrize(
Expand Down Expand Up @@ -1539,3 +1542,47 @@ def test_scalar_round_is_integer(con):

assert result == 1
assert isinstance(result, int)


@pytest.mark.parametrize(
"numbers",
[
param(
[1, 2, 3],
marks=[
pytest.mark.notyet(
["duckdb", "clickhouse", "datafusion"], raises=pa.ArrowInvalid
),
pytest.mark.notyet(
["pyspark"],
raises=(
# PySparkValueError is raised when using Spark connect
PySparkValueError,
TypeError,
),
),
],
id="ints",
),
param(
[decimal.Decimal("1.1"), decimal.Decimal("2.2"), decimal.Decimal("3.3")],
marks=[
pytest.mark.notimpl(
["sqlite"],
raises=(
sqlite3.ProgrammingError,
# With Python 3.10, the same code raises a different exception type :(
sqlite3.InterfaceError,
),
)
],
id="decimals",
),
],
)
@pytest.mark.notyet(["exasol"], raises=ExaQueryError)
def test_memtable_decimal(con, numbers):
schema = ibis.schema(dict(numbers=dt.Decimal(38, 9)))
t = ibis.memtable({"numbers": numbers}, schema=schema)
assert t.schema() == schema
assert len(con.to_pyarrow(t)) == len(numbers)

0 comments on commit 7ac1487

Please sign in to comment.