Merging upstream version 26.22.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ecad2ca6a9
commit
3552a78d82
69 changed files with 29194 additions and 28548 deletions
|
@ -177,6 +177,10 @@ class TestBigQuery(Validator):
|
|||
self.validate_identity(
|
||||
"CREATE OR REPLACE VIEW test (tenant_id OPTIONS (description='Test description on table creation')) AS SELECT 1 AS tenant_id, 1 AS customer_id",
|
||||
)
|
||||
self.validate_identity(
|
||||
"--c\nARRAY_AGG(v IGNORE NULLS)",
|
||||
"ARRAY_AGG(v IGNORE NULLS) /* c */",
|
||||
)
|
||||
self.validate_identity(
|
||||
'SELECT r"\\t"',
|
||||
"SELECT '\\\\t'",
|
||||
|
@ -1732,6 +1736,9 @@ WHERE
|
|||
)
|
||||
|
||||
def test_errors(self):
|
||||
with self.assertRaises(ParseError):
|
||||
self.parse_one("SELECT * FROM a - b.c.d2")
|
||||
|
||||
with self.assertRaises(TokenError):
|
||||
transpile("'\\'", read="bigquery")
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from sqlglot import (
|
|||
parse_one,
|
||||
)
|
||||
from sqlglot.dialects import BigQuery, Hive, Snowflake
|
||||
from sqlglot.dialects.dialect import Version
|
||||
from sqlglot.parser import logger as parser_logger
|
||||
|
||||
|
||||
|
@ -134,14 +135,25 @@ class TestDialect(Validator):
|
|||
"oracle, normalization_strategy = lowercase, version = 19.5"
|
||||
)
|
||||
self.assertEqual(oracle_with_settings.normalization_strategy.value, "LOWERCASE")
|
||||
self.assertEqual(oracle_with_settings.settings, {"version": "19.5"})
|
||||
self.assertEqual(oracle_with_settings.version, Version("19.5"))
|
||||
|
||||
bool_settings = Dialect.get_or_raise("oracle, s1=TruE, s2=1, s3=FaLse, s4=0, s5=nonbool")
|
||||
class MyDialect(Dialect):
|
||||
SUPPORTED_SETTINGS = {"s1", "s2", "s3", "s4", "s5"}
|
||||
|
||||
bool_settings = Dialect.get_or_raise("mydialect, s1=TruE, s2=1, s3=FaLse, s4=0, s5=nonbool")
|
||||
self.assertEqual(
|
||||
bool_settings.settings,
|
||||
{"s1": True, "s2": True, "s3": False, "s4": False, "s5": "nonbool"},
|
||||
)
|
||||
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
Dialect.get_or_raise("tsql,normalisation_strategy=case_sensitive")
|
||||
|
||||
self.assertEqual(
|
||||
"Unknown setting 'normalisation_strategy'. Did you mean normalization_strategy?",
|
||||
str(cm.exception),
|
||||
)
|
||||
|
||||
def test_compare_dialects(self):
|
||||
bigquery_class = Dialect["bigquery"]
|
||||
bigquery_object = BigQuery()
|
||||
|
@ -170,7 +182,9 @@ class TestDialect(Validator):
|
|||
|
||||
def test_compare_dialect_versions(self):
|
||||
ddb_v1 = Dialect.get_or_raise("duckdb, version=1.0")
|
||||
ddb_v1_2 = Dialect.get_or_raise("duckdb, foo=bar, version=1.0")
|
||||
ddb_v1_2 = Dialect.get_or_raise(
|
||||
"duckdb, normalization_strategy=case_sensitive, version=1.0"
|
||||
)
|
||||
ddb_v2 = Dialect.get_or_raise("duckdb, version=2.2.4")
|
||||
ddb_latest = Dialect.get_or_raise("duckdb")
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class TestDuckDB(Validator):
|
|||
dialect = "duckdb"
|
||||
|
||||
def test_duckdb(self):
|
||||
self.validate_identity("SELECT * FROM my_ducklake.demo AT (VERSION => 2)")
|
||||
self.validate_identity("SELECT UUIDV7()")
|
||||
self.validate_identity("SELECT TRY(LOG(0))")
|
||||
self.validate_identity("x::timestamp", "CAST(x AS TIMESTAMP)")
|
||||
|
|
|
@ -2667,3 +2667,25 @@ SINGLE = TRUE""",
|
|||
for node in (max_by, min_by):
|
||||
self.assertEqual(len(node.this.expressions), 1)
|
||||
self.assertIsInstance(node.expression, exp.Column)
|
||||
|
||||
def test_create_view_copy_grants(self):
|
||||
# for normal views, 'COPY GRANTS' goes *after* the column list. ref: https://docs.snowflake.com/en/sql-reference/sql/create-view#syntax
|
||||
self.validate_identity(
|
||||
"CREATE OR REPLACE VIEW FOO (A, B) COPY GRANTS AS SELECT A, B FROM TBL"
|
||||
)
|
||||
|
||||
# for materialized views, 'COPY GRANTS' must go *before* the column list or an error will be thrown. ref: https://docs.snowflake.com/en/sql-reference/sql/create-materialized-view#syntax
|
||||
self.validate_identity(
|
||||
"CREATE OR REPLACE MATERIALIZED VIEW FOO COPY GRANTS (A, B) AS SELECT A, B FROM TBL"
|
||||
)
|
||||
|
||||
# check that only 'COPY GRANTS' goes before the column list and other properties still go after
|
||||
self.validate_identity(
|
||||
"CREATE OR REPLACE MATERIALIZED VIEW FOO COPY GRANTS (A, B) COMMENT='foo' TAG (a='b') AS SELECT A, B FROM TBL"
|
||||
)
|
||||
|
||||
# no COPY GRANTS
|
||||
self.validate_identity("CREATE OR REPLACE VIEW FOO (A, B) AS SELECT A, B FROM TBL")
|
||||
self.validate_identity(
|
||||
"CREATE OR REPLACE MATERIALIZED VIEW FOO (A, B) AS SELECT A, B FROM TBL"
|
||||
)
|
||||
|
|
|
@ -1318,6 +1318,7 @@ WHERE
|
|||
)
|
||||
|
||||
def test_isnull(self):
|
||||
self.validate_identity("ISNULL(x, y)")
|
||||
self.validate_all("ISNULL(x, y)", write={"spark": "COALESCE(x, y)"})
|
||||
|
||||
def test_json(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue