Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clickhouse: CAST fails in various scenarios #1607

Closed
pkit opened this issue May 12, 2023 · 0 comments
Closed

clickhouse: CAST fails in various scenarios #1607

pkit opened this issue May 12, 2023 · 0 comments

Comments

@pkit
Copy link
Contributor

pkit commented May 12, 2023

SELECT
    CAST(['hello'], 'Array(Enum8(\'hello\' = 1))') AS x,
    (1, CAST('hello', 'Enum8(\'hello\' = 1)')) AS y
FORMAT PrettyCompactNoEscapes

Expected AS after CAST. Line 2, Col: 19.
  SELECT
    CAST(['hello']🔻,🔻 'Array(Enum8(\'hello\' = 1))') AS x,
    (1, CAST('hello', 'Enum8(\'hello\' = 1)')) AS y
FORMAT Pre
SELECT
    k,
    groupArray(x) AS res1,
    toTypeName(res1),
    avg(x) AS res2,
    toTypeName(res2)
FROM
(
    SELECT
        1 AS k,
        arrayJoin([1, NULL, 2]) AS x
    UNION ALL
    SELECT
        2 AS k,
        CAST(arrayJoin([NULL, NULL]), 'Nullable(UInt8)') AS x
)
GROUP BY k
ORDER BY k ASC

Expected AS after CAST. Line 15, Col: 37.
  oin([1, NULL, 2]) AS x
    UNION ALL
    SELECT
        2 AS k,
        CAST(arrayJoin([NULL, NULL])🔻,🔻 'Nullable(UInt8)') AS x
)
GROUP BY k
ORDER BY k ASC

SELECT CAST(if(number = 999999, NULL, number), 'UInt64')
FROM system.numbers
LIMIT 10

Expected AS after CAST. Line 1, Col: 47.
  SELECT CAST(if(number = 999999, NULL, number)🔻,🔻 'UInt64')
FROM system.numbers
LIMIT 10

Docs: https://clickhouse.com/docs/en/sql-reference/functions/type-conversion-functions#castx-t

@pkit pkit changed the title clickhouse: CAST fails in various scenarios clickhouse: CAST fails in various scenarios May 12, 2023
adrianisk pushed a commit to adrianisk/sqlglot that referenced this issue Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant