Data quality tests fail on ClickHouse tables with nested array columns: `ARRAY.__init__() missing 1 required positional argument: 'item_type'`
Affected module
Data Quality / Profiler
Describe the bug
Any test case on a ClickHouse table that has a column of type Array(Array(T)) fails before its SQL runs. The TestSuite workflow builds an SQLAlchemy ORM for the whole table, and the ORM type converter cannot build a nested array type. Every test on the table fails this way, including tableCustomSQLQuery, whose SQL does not touch the nested column. The profiler workflow builds the same ORM (profiler_source.py → SQASampler), so it is likely affected too; we have not run it.
To Reproduce
- In ClickHouse:
CREATE TABLE default.nested_array_repro (id UInt64, tags Array(Array(String))) ENGINE = MergeTree ORDER BY id; INSERT INTO default.nested_array_repro VALUES (1, [['a', 'b'], ['c']]); - Run metadata ingestion for the ClickHouse service so that the table appears in OpenMetadata.
- Create any table-level test case on it, for example
tableCustomSQLQuerywithSELECT count() FROM default.nested_array_repro WHERE id = 0, strategyCOUNT. - Create and run a TestSuite ingestion pipeline for the table.
The data quality step fails with an unhandled exception (frames in between omitted):
File "metadata/sampler/sqlalchemy/sampler.py", line 94, in __init__
self._table = self.build_table_orm(self.entity, self.service_connection_config, self.ometa_client)
...
File "metadata/profiler/orm/converter/base.py", line 95, in build_orm_col
type_=converter_registry[table_service_type]().map_types(col, table_service_type),
File "metadata/profiler/orm/converter/common.py", line 80, in map_types
return self._TYPE_MAP.get(col.dataType)(item_type=self._TYPE_MAP.get(col.arrayDataType))
...
File "sqlalchemy/sql/sqltypes.py", line 2996, in __init__
item_type = item_type()
File "sqlalchemy/sql/type_api.py", line 1710, in __init__
self.impl = to_instance(self.__class__.impl, *args, **kwargs)
TypeError: ARRAY.__init__() missing 1 required positional argument: 'item_type'
Expected behavior
The test runs. A nested array column is mapped to an array with an unknown element type, or skipped when the ORM is built.
OpenMetadata version
2.0.4 (server and ingestion). The same code is in 2.0.5-release and main (common.py line 78 on main).
OpenMetadata Ingestion package version
openmetadata-ingestion==2.0.4.0, SQLAlchemy 2.0.5x (the traceback line numbers match SQLAlchemy 2.0.52–2.0.54).
Additional context
Cause. DataType.ARRAY maps to CustomArray, a TypeDecorator with impl = ARRAY (ingestion/src/metadata/profiler/orm/types/custom_array.py). For a column with dataType = ARRAY and arrayDataType = ARRAY, map_types calls CustomArray(item_type=CustomArray). sqlalchemy.ARRAY instantiates a class passed as item_type without arguments, so the inner CustomArray() builds ARRAY() without item_type and fails. ClickHouse has no dialect-specific converter: converter_registry falls back to CommonMapTypes in common.py. CustomArray(item_type=CustomArray) reproduces the error outside the workflow.
Possible fix. In map_types, when col.arrayDataType == DataType.ARRAY, return CustomArray(item_type=sqlalchemy.types.NullType()) for the column instead of nesting array types (SQLAlchemy does not support nested ARRAY types), or map such columns to CustomTypes.UNDETERMINED.value.
Workaround we use. Ingest a view over the table without the nested array columns and attach the tests to the view. tableCustomSQLQuery runs its SQL through the service session, so the SQL can still read the original table. With computePassedFailedRowCount or a partitionExpression, the row count comes from the view, not from the table.
Related: #19241 (introduced the current item_type=self._TYPE_MAP.get(col.arrayDataType) mapping, fixing #19232), #6466 (array mapping in the BigQuery profiler), #13970 (nested arrays in Athena metadata ingestion), #15627 (open request for profiler support of complex data types).
Pre-submission checklist
- [x] I searched for duplicate issues.
- [x] I removed credentials, hostnames, emails, and other sensitive data from logs and config.