Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions tests/test_unsupported_arrow_types.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
#!/usr/bin/env python3

import unittest
import platform
import subprocess
import pyarrow as pa
import pyarrow.compute as pc
import chdb
from chdb import ChdbError


def is_musl_linux():
"""Check if running on musl Linux"""
if platform.system() != "Linux":
return False
try:
result = subprocess.run(['ldd', '--version'], capture_output=True, text=True)
print(f"stdout: {result.stdout.lower()}")
print(f"stderr: {result.stderr.lower()}")
# Check both stdout and stderr for musl
output_text = (result.stdout + result.stderr).lower()
return 'musl' in output_text
except Exception as e:
print(f"Exception in is_musl_linux: {e}")
return False


class TestUnsupportedArrowTypes(unittest.TestCase):
"""Test that chDB properly handles unsupported Arrow types"""

Expand All @@ -30,7 +48,8 @@ def test_sparse_union_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

def test_dense_union_type(self):
"""Test DENSE_UNION type - should fail"""
Expand All @@ -48,7 +67,8 @@ def test_dense_union_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

def test_interval_month_day_type(self):
"""Test INTERVAL_MONTH_DAY type - should fail"""
Expand Down Expand Up @@ -78,8 +98,10 @@ def test_interval_month_day_nano_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

@unittest.skipIf(is_musl_linux(), "Skip test on musl systems")
def test_list_view_type(self):
"""Test LIST_VIEW type - should fail"""
# Create list view array
Expand All @@ -90,8 +112,10 @@ def test_list_view_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

@unittest.skipIf(is_musl_linux(), "Skip test on musl systems")
def test_large_list_view_type(self):
"""Test LARGE_LIST_VIEW type - should fail"""
# Create large list view array (if available)
Expand All @@ -102,8 +126,10 @@ def test_large_list_view_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

@unittest.skipIf(is_musl_linux(), "Skip test on musl systems")
def test_run_end_encoded_type(self):
"""Test RUN_END_ENCODED type - should fail"""
# Create run-end encoded array
Expand All @@ -115,8 +141,10 @@ def test_run_end_encoded_type(self):
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")

self.assertIn("Unsupported", str(context.exception))
exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

@unittest.skipIf(is_musl_linux(), "Skip test on musl systems")
def test_skip_unsupported_columns_setting(self):
"""Test input_format_arrow_skip_columns_with_unsupported_types_in_schema_inference=1 skips unsupported columns"""
# Create a table with both supported and unsupported columns
Expand All @@ -137,7 +165,9 @@ def test_skip_unsupported_columns_setting(self):
# Without the setting, query should fail
with self.assertRaises(Exception) as context:
chdb.query("SELECT * FROM Python(table)")
self.assertIn("Unsupported", str(context.exception))

exception_str = str(context.exception)
self.assertTrue("unknown" in exception_str or "Unsupported" in exception_str)

# With the setting, query should succeed but skip unsupported column
result = chdb.query(
Expand Down
Loading