summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_sqlite.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-25 08:20:06 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-25 08:20:06 +0000
commitbd2d949d1f2fb728cf4c429dd3ae9a1510e10182 (patch)
treec051102e5aff0ca2d75e5b96b09968c52114060a /tests/dialects/test_sqlite.py
parentAdding upstream version 18.5.1. (diff)
downloadsqlglot-bd2d949d1f2fb728cf4c429dd3ae9a1510e10182.tar.xz
sqlglot-bd2d949d1f2fb728cf4c429dd3ae9a1510e10182.zip
Adding upstream version 18.7.0.upstream/18.7.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_sqlite.py')
-rw-r--r--tests/dialects/test_sqlite.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/dialects/test_sqlite.py b/tests/dialects/test_sqlite.py
index 4cf0832..3df74c8 100644
--- a/tests/dialects/test_sqlite.py
+++ b/tests/dialects/test_sqlite.py
@@ -59,6 +59,23 @@ class TestSQLite(Validator):
)
def test_sqlite(self):
+ self.validate_identity("SELECT DATE()")
+ self.validate_identity("SELECT DATE('now', 'start of month', '+1 month', '-1 day')")
+ self.validate_identity("SELECT DATETIME(1092941466, 'unixepoch')")
+ self.validate_identity("SELECT DATETIME(1092941466, 'auto')")
+ self.validate_identity("SELECT DATETIME(1092941466, 'unixepoch', 'localtime')")
+ self.validate_identity("SELECT UNIXEPOCH()")
+ self.validate_identity("SELECT STRFTIME('%s')")
+ self.validate_identity("SELECT JULIANDAY('now') - JULIANDAY('1776-07-04')")
+ self.validate_identity("SELECT UNIXEPOCH() - UNIXEPOCH('2004-01-01 02:34:56')")
+ self.validate_identity("SELECT DATE('now', 'start of year', '+9 months', 'weekday 2')")
+ self.validate_identity("SELECT (JULIANDAY('now') - 2440587.5) * 86400.0")
+ self.validate_identity("SELECT UNIXEPOCH('now', 'subsec')")
+ self.validate_identity("SELECT TIMEDIFF('now', '1809-02-12')")
+ self.validate_identity(
+ """SELECT item AS "item", some AS "some" FROM data WHERE (item = 'value_1' COLLATE NOCASE) AND (some = 't' COLLATE NOCASE) ORDER BY item ASC LIMIT 1 OFFSET 0"""
+ )
+
self.validate_all("SELECT LIKE(y, x)", write={"sqlite": "SELECT x LIKE y"})
self.validate_all("SELECT GLOB('*y*', 'xyz')", write={"sqlite": "SELECT 'xyz' GLOB '*y*'"})
self.validate_all(
@@ -112,8 +129,8 @@ class TestSQLite(Validator):
self.validate_all(
"SELECT fname, lname, age FROM person ORDER BY age DESC NULLS FIRST, fname ASC NULLS LAST, lname",
write={
- "spark": "SELECT fname, lname, age FROM person ORDER BY age DESC NULLS FIRST, fname NULLS LAST, lname",
- "sqlite": "SELECT fname, lname, age FROM person ORDER BY age DESC NULLS FIRST, fname NULLS LAST, lname",
+ "spark": "SELECT fname, lname, age FROM person ORDER BY age DESC NULLS FIRST, fname ASC NULLS LAST, lname",
+ "sqlite": "SELECT fname, lname, age FROM person ORDER BY age DESC NULLS FIRST, fname ASC NULLS LAST, lname",
},
)
self.validate_all("x", read={"snowflake": "LEAST(x)"})