diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py index 4c6747d161..6c76635c8a 100644 --- a/sqlglot/dialects/bigquery.py +++ b/sqlglot/dialects/bigquery.py @@ -753,8 +753,9 @@ class Generator(generator.Generator): exp.DataType.Type.TIMESTAMPTZ: "TIMESTAMP", exp.DataType.Type.TIMESTAMPLTZ: "TIMESTAMP", exp.DataType.Type.TINYINT: "INT64", - exp.DataType.Type.VARBINARY: "BYTES", exp.DataType.Type.ROWVERSION: "BYTES", + exp.DataType.Type.UUID: "STRING", + exp.DataType.Type.VARBINARY: "BYTES", exp.DataType.Type.VARCHAR: "STRING", exp.DataType.Type.VARIANT: "ANY TYPE", } diff --git a/tests/dialects/test_duckdb.py b/tests/dialects/test_duckdb.py index 18a030c6bd..98d1604bde 100644 --- a/tests/dialects/test_duckdb.py +++ b/tests/dialects/test_duckdb.py @@ -18,6 +18,13 @@ def test_duckdb(self): "WITH _data AS (SELECT [STRUCT(1 AS a, 2 AS b), STRUCT(2 AS a, 3 AS b)] AS col) SELECT col.b FROM _data, UNNEST(_data.col) AS col WHERE col.a = 1", ) + self.validate_all( + "CAST(x AS UUID)", + write={ + "bigquery": "CAST(x AS STRING)", + "duckdb": "CAST(x AS UUID)", + }, + ) self.validate_all( """SELECT CASE WHEN JSON_VALID('{"x: 1}') THEN '{"x: 1}' ELSE NULL END""", read={