aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/sql2yql/test_sql_format.py
diff options
context:
space:
mode:
authorMaxim Yurchuk <maxim-yurchuk@ydb.tech>2024-11-20 17:37:57 +0000
committerGitHub <noreply@github.com>2024-11-20 17:37:57 +0000
commitf76323e9b295c15751e51e3443aa47a36bee8023 (patch)
tree4113c8cad473a33e0f746966e0cf087252fa1d7a /yql/essentials/tests/sql/sql2yql/test_sql_format.py
parent753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff)
parenta7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff)
downloadydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yql/essentials/tests/sql/sql2yql/test_sql_format.py')
-rw-r--r--yql/essentials/tests/sql/sql2yql/test_sql_format.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/yql/essentials/tests/sql/sql2yql/test_sql_format.py b/yql/essentials/tests/sql/sql2yql/test_sql_format.py
new file mode 100644
index 0000000000..39780d7af9
--- /dev/null
+++ b/yql/essentials/tests/sql/sql2yql/test_sql_format.py
@@ -0,0 +1,29 @@
+import os
+import yatest.common
+import pytest
+
+from test_sql2yql import get_sql2yql_cmd
+from test_utils import pytest_generate_tests_by_template, DATA_PATH
+
+
+def pytest_generate_tests(metafunc):
+ return pytest_generate_tests_by_template('.sql', metafunc)
+
+
+def test(suite, case, tmpdir):
+ files = []
+ # case can contain slash because of nested suites
+ out_dir = tmpdir.mkdir(suite).mkdir(case.replace('/', '_')).dirname
+ case_file = os.path.join(DATA_PATH, suite, '%s.sql' % case)
+ ansi_lexer = False
+ with open(case_file, 'r') as f:
+ content = f.read()
+ ansi_lexer = 'ansi_lexer' in content
+ test_double_format = 'skip double format' not in content
+ if 'syntax_pg' in content:
+ pytest.skip('syntax_pg')
+ cmd = get_sql2yql_cmd(suite, case, case_file, out_dir=out_dir, ansi_lexer=ansi_lexer, test_format=True, test_double_format=test_double_format)
+ yatest.common.process.execute(cmd, env={'YQL_DETERMINISTIC_MODE': '1'})
+ files.append(os.path.join(out_dir, 'formatted.sql'))
+
+ return [yatest.common.canonical_file(file_name) for file_name in files]