From 6a22086850fc960715b618e82f4c2e43a4529146 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 20 Feb 2023 09:50:35 +0100 Subject: Merging upstream version 11.2.0. Signed-off-by: Daniel Baumann --- tests/dataframe/unit/test_session.py | 9 +++++++++ tests/dialects/test_dialect.py | 2 ++ tests/fixtures/identity.sql | 5 +++-- tests/fixtures/optimizer/pushdown_projections.sql | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/dataframe/unit/test_session.py b/tests/dataframe/unit/test_session.py index 5213667..f5b79fd 100644 --- a/tests/dataframe/unit/test_session.py +++ b/tests/dataframe/unit/test_session.py @@ -80,6 +80,15 @@ class TestDataframeSession(DataFrameSQLValidator): df.sql(pretty=False), ) + @mock.patch("sqlglot.schema", MappingSchema()) + def test_select_quoted(self): + sqlglot.schema.add_table('"TEST"', {"name": "string"}) + + self.assertEqual( + SparkSession().table('"TEST"').select(F.col("name")).sql(dialect="snowflake")[0], + '''SELECT "TEST"."name" AS "name" FROM "TEST" AS "TEST"''', + ) + @mock.patch("sqlglot.schema", MappingSchema()) def test_sql_with_aggs(self): # TODO: Do exact matches once CTE names are deterministic diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py index 5f048da..685dea4 100644 --- a/tests/dialects/test_dialect.py +++ b/tests/dialects/test_dialect.py @@ -422,9 +422,11 @@ class TestDialect(Validator): self.validate_all( "TS_OR_DS_TO_DATE(x)", write={ + "bigquery": "CAST(x AS DATE)", "duckdb": "CAST(x AS DATE)", "hive": "TO_DATE(x)", "presto": "CAST(SUBSTR(CAST(x AS VARCHAR), 1, 10) AS DATE)", + "snowflake": "CAST(x AS DATE)", }, ) self.validate_all( diff --git a/tests/fixtures/identity.sql b/tests/fixtures/identity.sql index 7b9ae6d..7c4ec8e 100644 --- a/tests/fixtures/identity.sql +++ b/tests/fixtures/identity.sql @@ -546,9 +546,10 @@ CREATE TABLE customer (pk BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WI CREATE TABLE customer (pk BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 10)) CREATE TABLE customer (pk BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (CYCLE)) CREATE TABLE foo (baz_id INT REFERENCES baz(id) DEFERRABLE) -CREATE TABLE foo (baz CHAR(4) CHARACTER SET LATIN UPPERCASE NOT CASESPECIFIC) -CREATE TABLE foo (baz DATE FORMAT 'YYYY/MM/DD' TITLE 'title') +CREATE TABLE foo (baz CHAR(4) CHARACTER SET LATIN UPPERCASE NOT CASESPECIFIC COMPRESS 'a') +CREATE TABLE foo (baz DATE FORMAT 'YYYY/MM/DD' TITLE 'title' INLINE LENGTH 1 COMPRESS ('a', 'b')) CREATE TABLE t (title TEXT) +CREATE TABLE foo (baz INT, inline TEXT) CREATE TABLE a, FALLBACK, LOG, JOURNAL, CHECKSUM=DEFAULT, DEFAULT MERGEBLOCKRATIO, BLOCKCOMPRESSION=MANUAL (a INT) CREATE TABLE a, NO FALLBACK PROTECTION, NO LOG, NO JOURNAL, CHECKSUM=ON, NO MERGEBLOCKRATIO, BLOCKCOMPRESSION=ALWAYS (a INT) CREATE TABLE a, WITH JOURNAL TABLE=x.y.z, CHECKSUM=OFF, MERGEBLOCKRATIO=1, DATABLOCKSIZE=10 KBYTES (a INT) diff --git a/tests/fixtures/optimizer/pushdown_projections.sql b/tests/fixtures/optimizer/pushdown_projections.sql index 107e92f..f3b1a69 100644 --- a/tests/fixtures/optimizer/pushdown_projections.sql +++ b/tests/fixtures/optimizer/pushdown_projections.sql @@ -50,7 +50,7 @@ SELECT x FROM UNNEST([1, 2]) AS q(x, y); SELECT q.x AS x FROM UNNEST(ARRAY(1, 2)) AS q(x, y); WITH t1 AS (SELECT cola, colb FROM UNNEST([STRUCT(1 AS cola, 'test' AS colb)]) AS "q"("cola", "colb")) SELECT cola FROM t1; -WITH t1 AS (SELECT q.cola AS cola FROM UNNEST(ARRAY(STRUCT(1 AS cola, 'test' AS colb))) AS "q"("cola", "colb")) SELECT t1.cola AS cola FROM t1; +WITH t1 AS (SELECT "q".cola AS cola FROM UNNEST(ARRAY(STRUCT(1 AS cola, 'test' AS colb))) AS "q"("cola", "colb")) SELECT t1.cola AS cola FROM t1; SELECT x FROM VALUES(1, 2) AS q(x, y); SELECT q.x AS x FROM (VALUES (1, 2)) AS q(x, y); -- cgit v1.2.3