1
0
Fork 0

Adding upstream version 10.4.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 15:01:11 +01:00
parent 275e9758ad
commit 63044b3f6c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
88 changed files with 1637 additions and 436 deletions

View file

@ -1,4 +1,5 @@
import datetime
import math
import unittest
from sqlglot import alias, exp, parse_one
@ -491,7 +492,7 @@ class TestExpressions(unittest.TestCase):
self.assertEqual(alias("foo", "bar-1").sql(), 'foo AS "bar-1"')
self.assertEqual(alias("foo", "bar_1").sql(), "foo AS bar_1")
self.assertEqual(alias("foo * 2", "2bar").sql(), 'foo * 2 AS "2bar"')
self.assertEqual(alias('"foo"', "_bar").sql(), '"foo" AS "_bar"')
self.assertEqual(alias('"foo"', "_bar").sql(), '"foo" AS _bar')
self.assertEqual(alias("foo", "bar", quoted=True).sql(), 'foo AS "bar"')
def test_unit(self):
@ -503,6 +504,8 @@ class TestExpressions(unittest.TestCase):
def test_identifier(self):
self.assertTrue(exp.to_identifier('"x"').quoted)
self.assertFalse(exp.to_identifier("x").quoted)
self.assertTrue(exp.to_identifier("foo ").quoted)
self.assertFalse(exp.to_identifier("_x").quoted)
def test_function_normalizer(self):
self.assertEqual(parse_one("HELLO()").sql(normalize_functions="lower"), "hello()")
@ -549,14 +552,15 @@ class TestExpressions(unittest.TestCase):
([1, "2", None], "ARRAY(1, '2', NULL)"),
({"x": None}, "MAP('x', NULL)"),
(
datetime.datetime(2022, 10, 1, 1, 1, 1),
"TIME_STR_TO_TIME('2022-10-01 01:01:01.000000')",
datetime.datetime(2022, 10, 1, 1, 1, 1, 1),
"TIME_STR_TO_TIME('2022-10-01T01:01:01.000001+00:00')",
),
(
datetime.datetime(2022, 10, 1, 1, 1, 1, tzinfo=datetime.timezone.utc),
"TIME_STR_TO_TIME('2022-10-01 01:01:01.000000+0000')",
"TIME_STR_TO_TIME('2022-10-01T01:01:01+00:00')",
),
(datetime.date(2022, 10, 1), "DATE_STR_TO_DATE('2022-10-01')"),
(math.nan, "NULL"),
]:
with self.subTest(value):
self.assertEqual(exp.convert(value).sql(), expected)