Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for query results of type Nothing and UUID regressed in 3.0.0 #302

Open
meastham opened this issue Feb 19, 2025 · 2 comments
Open

Comments

@meastham
Copy link

meastham commented Feb 19, 2025

Describe what's wrong

Queries with Nothing/UUID (and possibly other) types fail in 3.0.0 but were working in 2.x.

repro.py:

from chdb import dbapi
import traceback

conn = dbapi.connect()
cursor = conn.cursor()
for query in [
    "SELECT '6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b'::UUID",
    "SELECT NULL",
]:
    print(f"Query: {query}")
    try:
        cursor.execute(query)
        print(f"success: {cursor.fetchone()}")
    except Exception as e:
        print(f"failure:\n{traceback.format_exc()}")
    print()

Works fine with 2.x:

❯ uv run --python 3.12 --with chdb==2.1.1 repro.py
Query: SELECT '6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b'::UUID
success: ('6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b',)

Query: SELECT NULL
success: (None,)

Fails in 3.0.0:

uv run --python 3.12 --with chdb==3.0.0 repro.py
Query: SELECT '6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b'::UUID
failure:
Traceback (most recent call last):
  File "/Users/meastham/repro/repro.py", line 12, in <module>
    cursor.execute(query)
  File "/Users/meastham/.cache/uv/archive-v0/z1U-_q0CjtEXfAWREwnsj/lib/python3.12/site-packages/chdb/dbapi/cursors.py", line 132, in execute
    self._cursor.execute(query)
  File "/Users/meastham/.cache/uv/archive-v0/z1U-_q0CjtEXfAWREwnsj/lib/python3.12/site-packages/chdb/state/sqlitelike.py", line 46, in execute
    raise Exception(self._cursor.error_message())
Exception: Code: 50. DB::Exception: Code: 50. DB::Exception: The type 'UUID' of a column 'CAST('6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b', 'UUID')' is not supported for conversion into Arrow data format. (UNKNOWN_TYPE) (version 24.8.4.1). (UNKNOWN_TYPE)


Query: SELECT NULL
failure:
Traceback (most recent call last):
  File "/Users/meastham/repro/repro.py", line 12, in <module>
    cursor.execute(query)
  File "/Users/meastham/.cache/uv/archive-v0/z1U-_q0CjtEXfAWREwnsj/lib/python3.12/site-packages/chdb/dbapi/cursors.py", line 132, in execute
    self._cursor.execute(query)
  File "/Users/meastham/.cache/uv/archive-v0/z1U-_q0CjtEXfAWREwnsj/lib/python3.12/site-packages/chdb/state/sqlitelike.py", line 46, in execute
    raise Exception(self._cursor.error_message())
Exception: Code: 50. DB::Exception: Code: 50. DB::Exception: The type 'Nothing' of a column 'NULL' is not supported for conversion into Arrow data format. (UNKNOWN_TYPE) (version 24.8.4.1). (UNKNOWN_TYPE)

Does it reproduce on the most recent release?

Yes

Expected behavior

I expect these queries to succeed

@meastham
Copy link
Author

I originally repro'd this on MacOS 15.2 but it also happens on Linux:

❯ docker run --rm -it -v .:/tmp/repro ghcr.io/astral-sh/uv:debian uv run --python 3.12 --with chdb==3.0.0 /tmp/repro/repro.py
Installed 8 packages in 49ms
Query: SELECT '6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b'::UUID
failure:
Traceback (most recent call last):
  File "/tmp/repro/repro.py", line 12, in <module>
    cursor.execute(query)
  File "/root/.cache/uv/archive-v0/mobp6VEk6iq7wxUmoCwYi/lib/python3.12/site-packages/chdb/dbapi/cursors.py", line 132, in execute
    self._cursor.execute(query)
  File "/root/.cache/uv/archive-v0/mobp6VEk6iq7wxUmoCwYi/lib/python3.12/site-packages/chdb/state/sqlitelike.py", line 46, in execute
    raise Exception(self._cursor.error_message())
Exception: Code: 50. DB::Exception: Code: 50. DB::Exception: The type 'UUID' of a column 'CAST('6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b', 'UUID')' is not supported for conversion into Arrow data format. (UNKNOWN_TYPE) (version 24.8.4.1). (UNKNOWN_TYPE)


Query: SELECT NULL
failure:
Traceback (most recent call last):
  File "/tmp/repro/repro.py", line 12, in <module>
    cursor.execute(query)
  File "/root/.cache/uv/archive-v0/mobp6VEk6iq7wxUmoCwYi/lib/python3.12/site-packages/chdb/dbapi/cursors.py", line 132, in execute
    self._cursor.execute(query)
  File "/root/.cache/uv/archive-v0/mobp6VEk6iq7wxUmoCwYi/lib/python3.12/site-packages/chdb/state/sqlitelike.py", line 46, in execute
    raise Exception(self._cursor.error_message())
Exception: Code: 50. DB::Exception: Code: 50. DB::Exception: The type 'Nothing' of a column 'NULL' is not supported for conversion into Arrow data format. (UNKNOWN_TYPE) (version 24.8.4.1). (UNKNOWN_TYPE)

@auxten
Copy link
Member

auxten commented Feb 20, 2025

cursor.execute is using ArrowStream as internal type to impl the fetchone and fetchall.
But ArrowStream do not have complete types. This is a problem chDB should solve.

For now, you can use connect.query to work around this type issue like:
SELECT '6bbd51ac-b0cc-43a2-8cb2-eab06ff7de7b'::UUID

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants