From c77eeb23fc0cc5f92e0be1248c17a6ce8f5da07a Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Thu, 12 Oct 2023 15:43:49 -0400 Subject: [PATCH] feat(oracle): add support for loading Oracle RAW and BLOB types --- ibis/backends/oracle/datatypes.py | 2 ++ ibis/backends/oracle/tests/test_datatypes.py | 23 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 ibis/backends/oracle/tests/test_datatypes.py diff --git a/ibis/backends/oracle/datatypes.py b/ibis/backends/oracle/datatypes.py index 82d71bfbac4e..08cdc3be2e4f 100644 --- a/ibis/backends/oracle/datatypes.py +++ b/ibis/backends/oracle/datatypes.py @@ -15,6 +15,8 @@ class OracleType(AlchemyType): def to_ibis(cls, typ, nullable=True): if isinstance(typ, oracle.ROWID): return dt.String(nullable=nullable) + elif isinstance(typ, (oracle.RAW, sat.BLOB)): + return dt.Binary(nullable=nullable) elif isinstance(typ, sat.Float): return dt.Float64(nullable=nullable) elif isinstance(typ, sat.Numeric): diff --git a/ibis/backends/oracle/tests/test_datatypes.py b/ibis/backends/oracle/tests/test_datatypes.py new file mode 100644 index 000000000000..848bfd905e43 --- /dev/null +++ b/ibis/backends/oracle/tests/test_datatypes.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +import ibis + + +def test_failed_column_inference(con): + # This is a table in the Docker container that we know fails + # column type inference, so if is loaded, then we're in OK shape. + table = con.table("ALL_DOMAINS", schema="SYS") + assert len(table.columns) + + +def test_blob_raw(con): + con.drop_table("blob_raw_blobs_blob_raw", force=True) + + with con.begin() as bind: + bind.exec_driver_sql( + """CREATE TABLE "blob_raw_blobs_blob_raw" ("blob" BLOB, "raw" RAW(255))""" + ) + + raw_blob = con.table("blob_raw_blobs_blob_raw") + + assert raw_blob.schema() == ibis.Schema(dict(blob="binary", raw="binary"))