summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-24 18:46:57 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-06-24 18:46:57 +0000
commitcaf48491ccffa709546a473d36df6a4444164ad1 (patch)
treee803e4a815a9a39695e6161ec4feb55f295f4942 /tests
parentReleasing debian version 16.4.0-1. (diff)
downloadsqlglot-caf48491ccffa709546a473d36df6a4444164ad1.tar.xz
sqlglot-caf48491ccffa709546a473d36df6a4444164ad1.zip
Merging upstream version 16.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/dialects/test_databricks.py1
-rw-r--r--tests/dialects/test_snowflake.py9
-rw-r--r--tests/fixtures/pretty.sql15
-rw-r--r--tests/test_executor.py3
-rw-r--r--tests/test_expressions.py4
5 files changed, 27 insertions, 5 deletions
diff --git a/tests/dialects/test_databricks.py b/tests/dialects/test_databricks.py
index 8239dec..14f7cd0 100644
--- a/tests/dialects/test_databricks.py
+++ b/tests/dialects/test_databricks.py
@@ -5,6 +5,7 @@ class TestDatabricks(Validator):
dialect = "databricks"
def test_databricks(self):
+ self.validate_identity("INSERT INTO a REPLACE WHERE cond VALUES (1), (2)")
self.validate_identity("SELECT c1 : price")
self.validate_identity("CREATE FUNCTION a.b(x INT) RETURNS INT RETURN x + 1")
self.validate_identity("CREATE FUNCTION a AS b")
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 0514149..48bb2f7 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -23,19 +23,20 @@ class TestSnowflake(Validator):
self.validate_identity("CREATE TABLE foo (bar FLOAT AUTOINCREMENT START 0 INCREMENT 1)")
self.validate_identity("ALTER TABLE IF EXISTS foo SET TAG a = 'a', b = 'b', c = 'c'")
self.validate_identity("ALTER TABLE foo UNSET TAG a, b, c")
+ self.validate_identity("COMMENT IF EXISTS ON TABLE foo IS 'bar'")
+ self.validate_identity("SELECT CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', col)")
self.validate_identity(
'COPY INTO NEW_TABLE ("foo", "bar") FROM (SELECT $1, $2, $3, $4 FROM @%old_table)'
)
- self.validate_identity("COMMENT IF EXISTS ON TABLE foo IS 'bar'")
- self.validate_identity("SELECT CONVERT_TIMEZONE('UTC', 'America/Los_Angeles', col)")
+ self.validate_all("CAST(x AS BYTEINT)", write={"snowflake": "CAST(x AS INT)"})
self.validate_all("CAST(x AS CHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
+ self.validate_all("CAST(x AS CHARACTER VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
+ self.validate_all("CAST(x AS NCHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
self.validate_all(
"SELECT * FROM (VALUES (0) foo(bar))",
write={"snowflake": "SELECT * FROM (VALUES (0)) AS foo(bar)"},
)
- self.validate_all("CAST(x AS CHARACTER VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
- self.validate_all("CAST(x AS NCHAR VARYING)", write={"snowflake": "CAST(x AS VARCHAR)"})
self.validate_all(
"OBJECT_CONSTRUCT(a, b, c, d)",
read={
diff --git a/tests/fixtures/pretty.sql b/tests/fixtures/pretty.sql
index 8de9c85..46cd6d8 100644
--- a/tests/fixtures/pretty.sql
+++ b/tests/fixtures/pretty.sql
@@ -178,10 +178,23 @@ FROM (
) AS x;
INSERT OVERWRITE TABLE x VALUES (1, 2.0, '3.0'), (4, 5.0, '6.0');
-INSERT OVERWRITE TABLE x VALUES
+INSERT OVERWRITE TABLE x
+VALUES
(1, 2.0, '3.0'),
(4, 5.0, '6.0');
+INSERT INTO TABLE foo REPLACE WHERE cond SELECT * FROM bar;
+INSERT INTO foo
+REPLACE WHERE cond
+SELECT
+ *
+FROM bar;
+
+INSERT OVERWRITE TABLE zipcodes PARTITION(state = '0') VALUES (896, 'US', 'TAMPA', 33607);
+INSERT OVERWRITE TABLE zipcodes PARTITION(state = '0')
+VALUES
+ (896, 'US', 'TAMPA', 33607);
+
WITH regional_sales AS (
SELECT region, SUM(amount) AS total_sales
FROM orders
diff --git a/tests/test_executor.py b/tests/test_executor.py
index bb01dee..3a37cd4 100644
--- a/tests/test_executor.py
+++ b/tests/test_executor.py
@@ -580,6 +580,7 @@ class TestExecutor(unittest.TestCase):
("INTERVAL '1' week", datetime.timedelta(weeks=1)),
("1 IN (1, 2, 3)", True),
("1 IN (2, 3)", False),
+ ("1 IN (1)", True),
("NULL IS NULL", True),
("NULL IS NOT NULL", False),
("NULL = NULL", None),
@@ -612,6 +613,8 @@ class TestExecutor(unittest.TestCase):
("STRFTIME('%j', NULL)", None),
("DATESTRTODATE('2022-01-01')", date(2022, 1, 1)),
("TIMESTRTOTIME('2022-01-01')", datetime.datetime(2022, 1, 1)),
+ ("LEFT('12345', 3)", "123"),
+ ("RIGHT('12345', 3)", "345"),
]:
with self.subTest(sql):
result = execute(f"SELECT {sql}")
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index e7a37f3..f83addb 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -179,6 +179,10 @@ class TestExpressions(unittest.TestCase):
self.assertEqual(exp.table_name(parse_one("a.b", into=exp.Table)), "a.b")
self.assertEqual(exp.table_name(parse_one("a.b.c", into=exp.Table)), "a.b.c")
self.assertEqual(exp.table_name("a.b.c"), "a.b.c")
+ self.assertEqual(
+ exp.table_name(parse_one("foo.`{bar,er}`", read="databricks"), dialect="databricks"),
+ "foo.`{bar,er}`",
+ )
def test_table(self):
self.assertEqual(exp.table_("a", alias="b"), parse_one("select * from a b").find(exp.Table))