Skip to content

Clickhouse: Can't parse data type from complex expression #7701

Description

@ultram4rine

Before you file an issue

  • Make sure you specify the "read" dialect eg. parse_one(sql, read="spark")
  • Make sure you specify the "write" dialect eg. ast.sql(dialect="duckdb")
  • Check if the issue still exists on main

Fully reproducible code snippet
Please include a fully reproducible code snippet or the input sql, dialect, and expected output.

ct = """Tuple(
        arr1 Array(String),
        arr2 Array(Tuple(c1 String, c2 Int64)
        )"""
exp.DataType.build(dtype=ct, dialect="clickhouse")
raise ParseError(f"No expression was parsed from '{sql}'")
sqlglot.errors.ParseError: No expression was parsed from 'Tuple(
        arr1 Array(String),
        arr2 Array(Tuple(c1 String, c2 Int64)
        )'

However, this works:

ct = """Tuple(
        arr1 Array(Tuple(c1 String, c2 String)),
        arr2 Array(Tuple(c1 String, c2 Int32)))"""
exp.DataType.build(dtype=ct, dialect="clickhouse")
STRUCT<arr1 ARRAY<STRUCT<c1 TEXT, c2 TEXT>>, arr2 ARRAY<STRUCT<c1 TEXT, c2 INT>>>

My actual data type is a lot more, like Tuple(DateTime64(3, 'UTC'), Int64, Nullable(String), String, ..., Array(Tuple(String, Int64, Nullable(String), ...)), Array(Tuple(...))), so I've tried to locate the problem

Official Documentation
Please include links to official SQL documentation related to your issue.

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