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.py78
1 files changed, 45 insertions, 33 deletions
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index c28c58d..1ac910c 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -18,48 +18,60 @@ class TestSnowflake(Validator):
self.validate_identity("COMMENT IF EXISTS ON TABLE foo IS 'bar'")
self.validate_all(
- "1 / 2",
+ "TO_CHAR(x, y)",
read={
- "bigquery": "1 / 2",
- "clickhouse": "1 / 2",
- "databricks": "1 / 2",
- "hive": "1 / 2",
- "mysql": "1 / 2",
- "oracle": "1 / 2",
- "snowflake": "1 / 2",
- "spark": "1 / 2",
- "starrocks": "1 / 2",
- },
- write={
- "bigquery": "1 / 2",
- "clickhouse": "1 / 2",
- "databricks": "1 / 2",
- "hive": "1 / 2",
- "mysql": "1 / 2",
- "oracle": "1 / 2",
- "snowflake": "1 / 2",
- "spark": "1 / 2",
- "starrocks": "1 / 2",
- "drill": "CAST(1 AS DOUBLE) / 2",
- "duckdb": "CAST(1 AS DOUBLE) / 2",
- "postgres": "CAST(1 AS DOUBLE PRECISION) / 2",
- "presto": "CAST(1 AS DOUBLE) / 2",
- "redshift": "CAST(1 AS DOUBLE PRECISION) / 2",
- "sqlite": "CAST(1 AS REAL) / 2",
- "teradata": "CAST(1 AS DOUBLE) / 2",
- "trino": "CAST(1 AS DOUBLE) / 2",
- "tsql": "CAST(1 AS DOUBLE) / 2",
+ "": "TO_CHAR(x, y)",
+ "snowflake": "TO_VARCHAR(x, y)",
+ },
+ write={
+ "": "CAST(x AS TEXT)",
+ "databricks": "TO_CHAR(x, y)",
+ "drill": "TO_CHAR(x, y)",
+ "oracle": "TO_CHAR(x, y)",
+ "postgres": "TO_CHAR(x, y)",
+ "snowflake": "TO_CHAR(x, y)",
+ "teradata": "TO_CHAR(x, y)",
+ },
+ )
+ self.validate_all(
+ "SQUARE(x)",
+ write={
+ "bigquery": "POWER(x, 2)",
+ "clickhouse": "POWER(x, 2)",
+ "databricks": "POWER(x, 2)",
+ "drill": "POW(x, 2)",
+ "duckdb": "POWER(x, 2)",
+ "hive": "POWER(x, 2)",
+ "mysql": "POWER(x, 2)",
+ "oracle": "POWER(x, 2)",
+ "postgres": "x ^ 2",
+ "presto": "POWER(x, 2)",
+ "redshift": "POWER(x, 2)",
+ "snowflake": "POWER(x, 2)",
+ "spark": "POWER(x, 2)",
+ "sqlite": "POWER(x, 2)",
+ "starrocks": "POWER(x, 2)",
+ "trino": "POWER(x, 2)",
+ "tsql": "POWER(x, 2)",
+ },
+ )
+ self.validate_all(
+ "POWER(x, 2)",
+ read={
+ "oracle": "SQUARE(x)",
+ "snowflake": "SQUARE(x)",
+ "tsql": "SQUARE(x)",
},
)
self.validate_all(
"DIV0(foo, bar)",
write={
"snowflake": "IFF(bar = 0, 0, foo / bar)",
- "sqlite": "CASE WHEN bar = 0 THEN 0 ELSE CAST(foo AS REAL) / bar END",
- "presto": "IF(bar = 0, 0, CAST(foo AS DOUBLE) / bar)",
+ "sqlite": "CASE WHEN bar = 0 THEN 0 ELSE foo / bar END",
+ "presto": "IF(bar = 0, 0, foo / bar)",
"spark": "IF(bar = 0, 0, foo / bar)",
"hive": "IF(bar = 0, 0, foo / bar)",
- "duckdb": "CASE WHEN bar = 0 THEN 0 ELSE CAST(foo AS DOUBLE) / bar END",
+ "duckdb": "CASE WHEN bar = 0 THEN 0 ELSE foo / bar END",
},
)
self.validate_all(