Skip to content

Reflection fails on complex nested types #269

@hsheth2

Description

@hsheth2

Describe the bug

For a table DDL like this:

CREATE TABLE IF NOT EXISTS bugtable on cluster 'local' (
	id Int,
	metadata Map(String, Map(String, Nullable(String)))
) ENGINE = MergeTree()
order by id

Reflection using get_columns() fails with Map.__init__() missing 1 required positional argument: 'value_type'

It looks like the issue is in this code

elif spec.startswith('Map'):
inner = spec[4:-1]
coltype = self.ischema_names['_map']
inner_types = [
self._get_column_type(name, t.strip())
for t in inner.split(',')
]
- the .split(',') is getting an input of String, Map(String, Nullable(String)) and splits it to [String, 'Map(String', 'Nullable(String))'] - it doesn't respect the parentheses. It could probably be replaced with a .split(',', maxsplit=1) to fix this issue (unless the key type was also complex, but that seems less likely)

Expected behavior
This should get reflected properly.

Originally discovered in the DataHub slack community: https://datahubspace.slack.com/archives/CUMUWQU66/p1698241313514559?thread_ts=1698112545.709559&cid=CUMUWQU66

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions