From 9eb1ed17673a6ab75e76eebc79d85d66444e0aa6 Mon Sep 17 00:00:00 2001 From: Jiting Xu <126802425+jitingxu1@users.noreply.github.com> Date: Wed, 5 Jun 2024 02:28:55 -0700 Subject: [PATCH] fix(datatypes): manually cast the type of `pos` to `int16` for `table.info()` (#9139) --- ibis/backends/tests/test_generic.py | 17 +++++++++++++++++ ibis/expr/types/relations.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ibis/backends/tests/test_generic.py b/ibis/backends/tests/test_generic.py index 3d2a7b728ddb..9c39170f193d 100644 --- a/ibis/backends/tests/test_generic.py +++ b/ibis/backends/tests/test_generic.py @@ -617,6 +617,23 @@ def test_table_info(alltypes): assert expr.columns == list(df.columns) +@pytest.mark.notyet( + ["druid"], + raises=PyDruidProgrammingError, + reason="Druid only supports trivial unions", +) +@pytest.mark.notyet( + ["flink"], reason="IOException - Insufficient number of network buffers" +) +def test_table_info_large(con): + num_cols = 129 + col_names = [f"col_{i}" for i in range(num_cols)] + t = ibis.memtable({col: [0, 1] for col in col_names}) + result = con.execute(t.info()) + assert list(result.name) == col_names + assert result.pos.dtype == np.int16 + + @pytest.mark.notimpl( [ "datafusion", diff --git a/ibis/expr/types/relations.py b/ibis/expr/types/relations.py index 3a28e0846f7c..64a79ff1f963 100644 --- a/ibis/expr/types/relations.py +++ b/ibis/expr/types/relations.py @@ -2865,7 +2865,7 @@ def info(self) -> Table: nulls=lambda t: t.isna.sum(), non_nulls=lambda t: (1 - t.isna).sum(), null_frac=lambda t: t.isna.mean(), - pos=lit(pos), + pos=lit(pos, type=dt.int16), ) aggs.append(agg) return ibis.union(*aggs).order_by(ibis.asc("pos"))