summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_snowflake.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-10 11:29:00 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-10 11:29:00 +0000
commit74b38d30f43f7005428e09fa80508c5f21324c99 (patch)
tree7a0d4e49fffdc0330fc941c6528d3c8669a2acc6 /tests/dialects/test_snowflake.py
parentAdding upstream version 6.2.8. (diff)
downloadsqlglot-74b38d30f43f7005428e09fa80508c5f21324c99.tar.xz
sqlglot-74b38d30f43f7005428e09fa80508c5f21324c99.zip
Adding upstream version 6.3.1.upstream/6.3.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_snowflake.py')
-rw-r--r--tests/dialects/test_snowflake.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 2145966..8a33e2d 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -305,3 +305,35 @@ class TestSnowflake(Validator):
self.validate_identity(
"CREATE PROCEDURE a.b.c(x INT, y VARIANT) RETURNS OBJECT EXECUTE AS CALLER AS 'BEGIN SELECT 1; END;'"
)
+
+ def test_table_literal(self):
+ # All examples from https://docs.snowflake.com/en/sql-reference/literals-table.html
+ self.validate_all(
+ r"""SELECT * FROM TABLE('MYTABLE')""", write={"snowflake": r"""SELECT * FROM TABLE('MYTABLE')"""}
+ )
+
+ self.validate_all(
+ r"""SELECT * FROM TABLE('MYDB."MYSCHEMA"."MYTABLE"')""",
+ write={"snowflake": r"""SELECT * FROM TABLE('MYDB."MYSCHEMA"."MYTABLE"')"""},
+ )
+
+ # Per Snowflake documentation at https://docs.snowflake.com/en/sql-reference/literals-table.html
+ # one can use either a " ' " or " $$ " to enclose the object identifier.
+ # Capturing the single tokens seems like lot of work. Hence adjusting tests to use these interchangeably,
+ self.validate_all(
+ r"""SELECT * FROM TABLE($$MYDB. "MYSCHEMA"."MYTABLE"$$)""",
+ write={"snowflake": r"""SELECT * FROM TABLE('MYDB. "MYSCHEMA"."MYTABLE"')"""},
+ )
+
+ self.validate_all(r"""SELECT * FROM TABLE($MYVAR)""", write={"snowflake": r"""SELECT * FROM TABLE($MYVAR)"""})
+
+ self.validate_all(r"""SELECT * FROM TABLE(?)""", write={"snowflake": r"""SELECT * FROM TABLE(?)"""})
+
+ self.validate_all(
+ r"""SELECT * FROM TABLE(:BINDING)""", write={"snowflake": r"""SELECT * FROM TABLE(:BINDING)"""}
+ )
+
+ self.validate_all(
+ r"""SELECT * FROM TABLE($MYVAR) WHERE COL1 = 10""",
+ write={"snowflake": r"""SELECT * FROM TABLE($MYVAR) WHERE COL1 = 10"""},
+ )