summaryrefslogtreecommitdiffstats
path: root/tests/test_expressions.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-01-17 10:32:16 +0000
commitd3bb537b2b73788ba06bf4158f473ecc5bb556cc (patch)
tree6c1b280de128c7bf77baaa258560a1f39a4e15c7 /tests/test_expressions.py
parentReleasing debian version 10.4.2-1. (diff)
downloadsqlglot-d3bb537b2b73788ba06bf4158f473ecc5bb556cc.tar.xz
sqlglot-d3bb537b2b73788ba06bf4158f473ecc5bb556cc.zip
Merging upstream version 10.5.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_expressions.py')
-rw-r--r--tests/test_expressions.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index 1e23983..906e08c 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -646,3 +646,72 @@ FROM foo""",
exp.Column(this=exp.to_identifier("colb")),
],
)
+
+ def test_values(self):
+ self.assertEqual(
+ exp.values([(1, 2), (3, 4)], "t", ["a", "b"]).sql(),
+ "(VALUES (1, 2), (3, 4)) AS t(a, b)",
+ )
+ self.assertEqual(
+ exp.values(
+ [(1, 2), (3, 4)],
+ "t",
+ {"a": exp.DataType.build("TEXT"), "b": exp.DataType.build("TEXT")},
+ ).sql(),
+ "(VALUES (CAST(1 AS TEXT), CAST(2 AS TEXT)), (3, 4)) AS t(a, b)",
+ )
+ with self.assertRaises(ValueError):
+ exp.values([(1, 2), (3, 4)], columns=["a"])
+
+ def test_data_type_builder(self):
+ self.assertEqual(exp.DataType.build("TEXT").sql(), "TEXT")
+ self.assertEqual(exp.DataType.build("DECIMAL(10, 2)").sql(), "DECIMAL(10, 2)")
+ self.assertEqual(exp.DataType.build("VARCHAR(255)").sql(), "VARCHAR(255)")
+ self.assertEqual(exp.DataType.build("ARRAY<INT>").sql(), "ARRAY<INT>")
+ self.assertEqual(exp.DataType.build("CHAR").sql(), "CHAR")
+ self.assertEqual(exp.DataType.build("NCHAR").sql(), "CHAR")
+ self.assertEqual(exp.DataType.build("VARCHAR").sql(), "VARCHAR")
+ self.assertEqual(exp.DataType.build("NVARCHAR").sql(), "VARCHAR")
+ self.assertEqual(exp.DataType.build("TEXT").sql(), "TEXT")
+ self.assertEqual(exp.DataType.build("BINARY").sql(), "BINARY")
+ self.assertEqual(exp.DataType.build("VARBINARY").sql(), "VARBINARY")
+ self.assertEqual(exp.DataType.build("INT").sql(), "INT")
+ self.assertEqual(exp.DataType.build("TINYINT").sql(), "TINYINT")
+ self.assertEqual(exp.DataType.build("SMALLINT").sql(), "SMALLINT")
+ self.assertEqual(exp.DataType.build("BIGINT").sql(), "BIGINT")
+ self.assertEqual(exp.DataType.build("FLOAT").sql(), "FLOAT")
+ self.assertEqual(exp.DataType.build("DOUBLE").sql(), "DOUBLE")
+ self.assertEqual(exp.DataType.build("DECIMAL").sql(), "DECIMAL")
+ self.assertEqual(exp.DataType.build("BOOLEAN").sql(), "BOOLEAN")
+ self.assertEqual(exp.DataType.build("JSON").sql(), "JSON")
+ self.assertEqual(exp.DataType.build("JSONB").sql(), "JSONB")
+ self.assertEqual(exp.DataType.build("INTERVAL").sql(), "INTERVAL")
+ self.assertEqual(exp.DataType.build("TIME").sql(), "TIME")
+ self.assertEqual(exp.DataType.build("TIMESTAMP").sql(), "TIMESTAMP")
+ self.assertEqual(exp.DataType.build("TIMESTAMPTZ").sql(), "TIMESTAMPTZ")
+ self.assertEqual(exp.DataType.build("TIMESTAMPLTZ").sql(), "TIMESTAMPLTZ")
+ self.assertEqual(exp.DataType.build("DATE").sql(), "DATE")
+ self.assertEqual(exp.DataType.build("DATETIME").sql(), "DATETIME")
+ self.assertEqual(exp.DataType.build("ARRAY").sql(), "ARRAY")
+ self.assertEqual(exp.DataType.build("MAP").sql(), "MAP")
+ self.assertEqual(exp.DataType.build("UUID").sql(), "UUID")
+ self.assertEqual(exp.DataType.build("GEOGRAPHY").sql(), "GEOGRAPHY")
+ self.assertEqual(exp.DataType.build("GEOMETRY").sql(), "GEOMETRY")
+ self.assertEqual(exp.DataType.build("STRUCT").sql(), "STRUCT")
+ self.assertEqual(exp.DataType.build("NULLABLE").sql(), "NULLABLE")
+ self.assertEqual(exp.DataType.build("HLLSKETCH").sql(), "HLLSKETCH")
+ self.assertEqual(exp.DataType.build("HSTORE").sql(), "HSTORE")
+ self.assertEqual(exp.DataType.build("SUPER").sql(), "SUPER")
+ self.assertEqual(exp.DataType.build("SERIAL").sql(), "SERIAL")
+ self.assertEqual(exp.DataType.build("SMALLSERIAL").sql(), "SMALLSERIAL")
+ self.assertEqual(exp.DataType.build("BIGSERIAL").sql(), "BIGSERIAL")
+ self.assertEqual(exp.DataType.build("XML").sql(), "XML")
+ self.assertEqual(exp.DataType.build("UNIQUEIDENTIFIER").sql(), "UNIQUEIDENTIFIER")
+ self.assertEqual(exp.DataType.build("MONEY").sql(), "MONEY")
+ self.assertEqual(exp.DataType.build("SMALLMONEY").sql(), "SMALLMONEY")
+ self.assertEqual(exp.DataType.build("ROWVERSION").sql(), "ROWVERSION")
+ self.assertEqual(exp.DataType.build("IMAGE").sql(), "IMAGE")
+ self.assertEqual(exp.DataType.build("VARIANT").sql(), "VARIANT")
+ self.assertEqual(exp.DataType.build("OBJECT").sql(), "OBJECT")
+ self.assertEqual(exp.DataType.build("NULL").sql(), "NULL")
+ self.assertEqual(exp.DataType.build("UNKNOWN").sql(), "UNKNOWN")