diff --git a/ibis/backends/tests/test_generic.py b/ibis/backends/tests/test_generic.py index 0ca4dc1be0a6..9e6c90cabf0d 100644 --- a/ibis/backends/tests/test_generic.py +++ b/ibis/backends/tests/test_generic.py @@ -1065,15 +1065,10 @@ def test_int_column(alltypes): assert result.dtype == np.int8 -@pytest.mark.notimpl(["druid", "oracle"]) -@pytest.mark.never( - ["bigquery", "sqlite", "snowflake"], reason="backend only implements int64" -) def test_int_scalar(alltypes): expr = alltypes.int_col.min() - result = expr.execute() - assert expr.type() == dt.int32 - assert result.dtype == np.int32 + assert expr.type().is_integer() + assert isinstance(expr.execute(), int) @pytest.mark.notimpl(["datafusion", "polars", "druid"]) diff --git a/ibis/expr/api.py b/ibis/expr/api.py index e89ed7b8ee99..153dc4e765df 100644 --- a/ibis/expr/api.py +++ b/ibis/expr/api.py @@ -199,11 +199,11 @@ def param(type: dt.DataType) -> ir.Scalar: ... ) >>> expr = t.filter(t.date_col >= start).value.sum() >>> expr.execute(params={start: date(2013, 1, 1)}) - np.float64(6.0) + 6.0 >>> expr.execute(params={start: date(2013, 1, 2)}) - np.float64(5.0) + 5.0 >>> expr.execute(params={start: date(2013, 1, 3)}) - np.float64(3.0) + 3.0 """ return ops.ScalarParameter(type).to_expr() diff --git a/ibis/expr/operations/udf.py b/ibis/expr/operations/udf.py index ee73dfae8b64..818d4a96df9a 100644 --- a/ibis/expr/operations/udf.py +++ b/ibis/expr/operations/udf.py @@ -239,8 +239,7 @@ def builtin( >>> expr = hamming("duck", "luck") >>> con = ibis.connect("duckdb://") >>> con.execute(expr) - np.int64(1) - + 1 """ return _wrap( cls._make_wrapper, diff --git a/ibis/formats/pandas.py b/ibis/formats/pandas.py index 7440ff386c6b..c9336526a382 100644 --- a/ibis/formats/pandas.py +++ b/ibis/formats/pandas.py @@ -149,7 +149,18 @@ def convert_column(cls, obj, dtype): @classmethod def convert_scalar(cls, obj, dtype): df = PandasData.convert_table(obj, sch.Schema({str(obj.columns[0]): dtype})) - return df.iat[0, 0] + value = df.iat[0, 0] + + if dtype.is_array(): + try: + return value.tolist() + except AttributeError: + return value + + try: + return value.item() + except AttributeError: + return value @classmethod def convert_GeoSpatial(cls, s, dtype, pandas_type):