Skip to content

Commit

Permalink
Revert "remove table with _ne suffix creation (#13002)"
Browse files Browse the repository at this point in the history
This reverts commit 9855159.
  • Loading branch information
zverevgeny committed Jan 4, 2025
1 parent 46a54ec commit 254fcb3
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions ydb/tests/functional/suite_tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def is_statement_definition(line):
return line.startswith("statement")


def patch_yql_statement(lines_or_statement, table_path_prefix):
def format_yql_statement(lines_or_statement, table_path_prefix):
if not isinstance(lines_or_statement, list):
lines_or_statement = [lines_or_statement]
statement = "\n".join(
Expand Down Expand Up @@ -254,6 +254,7 @@ def setup_class(cls):
)
cls.cluster.start()
cls.table_path_prefix = None
cls.table_path_prefix_ne = None
cls.driver = ydb.Driver(ydb.DriverConfig(
database="/Root",
endpoint="%s:%s" % (cls.cluster.nodes[1].host, cls.cluster.nodes[1].port)))
Expand All @@ -275,6 +276,7 @@ def run_sql_suite(self, kind, *path_pieces):
self.plan = (kind == 'plan')
self.query_id = itertools.count(start=1)
self.table_path_prefix = "/Root/%s" % '_'.join(list(path_pieces) + [kind])
self.table_path_prefix_ne = self.table_path_prefix + "_ne"
for parsed_statement in get_statements(get_source_path(*path_pieces), os.path.join(*path_pieces)):
self.assert_statement(parsed_statement)
return self.files
Expand Down Expand Up @@ -413,7 +415,7 @@ def assert_statement_stream_query(self, statement):
if self.plan:
return

yql_text = patch_yql_statement(statement.text, self.table_path_prefix)
yql_text = format_yql_statement(statement.text, self.table_path_prefix)
yql_text = "--!syntax_v1\n" + yql_text + "\n\n"
result = self.execute_scan_query(yql_text)
file_name = statement.suite_name.split('/')[1] + '.out'
Expand All @@ -440,26 +442,19 @@ def execute_ydb_ok(self, statement_text):
self.execute_query(statement_text)

def explain(self, query):
yql_text = patch_yql_statement(query, self.table_path_prefix)
# seems explain not working with query service ?
"""
result_sets = self.pool.execute_with_retries(yql_text, exec_mode=ydb.query.base.QueryExecMode.EXPLAIN)
first_set = result_sets[0]
print("***", first_set)
print("***", first_set.rows)
return first_set.rows[0]
"""

return self.legacy_pool.retry_operation_sync(lambda s: s.explain(yql_text)).query_plan
yql_text = format_yql_statement(query, self.table_path_prefix)
return self.pool.retry_operation_sync(lambda s: s.explain(yql_text)).query_plan

def execute_scheme(self, statement_text):
yql_text = patch_yql_statement(statement_text, self.table_path_prefix)
self.pool.execute_with_retries(yql_text)
yql_text = format_yql_statement(statement_text, self.table_path_prefix)
self.pool.retry_operation_sync(lambda s: s.execute_scheme(yql_text))
yql_text = format_yql_statement(statement_text, self.table_path_prefix_ne)
self.pool.retry_operation_sync(lambda s: s.execute_scheme(yql_text))
return None

def execute_query(self, statement_text):
yql_text = patch_yql_statement(statement_text, self.table_path_prefix)
result = self.pool.execute_with_retries(yql_text)
yql_text = format_yql_statement(statement_text, self.table_path_prefix)
result = self.pool.retry_operation_sync(lambda s: s.transaction().execute(yql_text, commit_tx=True))

if len(result) == 1:
scan_query_result = self.execute_scan_query(yql_text)
Expand Down

0 comments on commit 254fcb3

Please sign in to comment.