summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_snowflake.py
diff options
context:
space:
mode:
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"""},
+ )