diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-02-20 09:37:57 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-02-20 09:37:57 +0000 |
commit | 5c70c63284a8ff61607db1a51ac2829b74f71c1c (patch) | |
tree | 10a81ffbd8da8cae58e292848cbdd0550d08721d /tests/dialects/test_tsql.py | |
parent | Adding upstream version 21.1.1. (diff) | |
download | sqlglot-5c70c63284a8ff61607db1a51ac2829b74f71c1c.tar.xz sqlglot-5c70c63284a8ff61607db1a51ac2829b74f71c1c.zip |
Adding upstream version 21.1.2.upstream/21.1.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_tsql.py')
-rw-r--r-- | tests/dialects/test_tsql.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py index e2ec15b..a304a9e 100644 --- a/tests/dialects/test_tsql.py +++ b/tests/dialects/test_tsql.py @@ -920,28 +920,48 @@ WHERE self.assertEqual(expr.sql(dialect="tsql"), expected_sql) def test_charindex(self): + self.validate_identity( + "SELECT CAST(SUBSTRING('ABCD~1234', CHARINDEX('~', 'ABCD~1234') + 1, LEN('ABCD~1234')) AS BIGINT)" + ) + self.validate_all( "CHARINDEX(x, y, 9)", + read={ + "spark": "LOCATE(x, y, 9)", + }, write={ "spark": "LOCATE(x, y, 9)", + "tsql": "CHARINDEX(x, y, 9)", }, ) self.validate_all( "CHARINDEX(x, y)", + read={ + "spark": "LOCATE(x, y)", + }, write={ "spark": "LOCATE(x, y)", + "tsql": "CHARINDEX(x, y)", }, ) self.validate_all( "CHARINDEX('sub', 'testsubstring', 3)", + read={ + "spark": "LOCATE('sub', 'testsubstring', 3)", + }, write={ "spark": "LOCATE('sub', 'testsubstring', 3)", + "tsql": "CHARINDEX('sub', 'testsubstring', 3)", }, ) self.validate_all( "CHARINDEX('sub', 'testsubstring')", + read={ + "spark": "LOCATE('sub', 'testsubstring')", + }, write={ "spark": "LOCATE('sub', 'testsubstring')", + "tsql": "CHARINDEX('sub', 'testsubstring')", }, ) |