diff --git a/tests/test_unsupported_arrow_types.py b/tests/test_unsupported_arrow_types.py index 88640876e1f..df783ebe388 100644 --- a/tests/test_unsupported_arrow_types.py +++ b/tests/test_unsupported_arrow_types.py @@ -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""" @@ -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""" @@ -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""" @@ -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 @@ -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) @@ -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 @@ -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 @@ -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(