From ed24bb6783d10889818c5c69c59de5caf50f375f Mon Sep 17 00:00:00 2001 From: Maxim Yurchuk Date: Tue, 24 Dec 2024 15:17:01 +0000 Subject: [PATCH] Move dynamber to sql tests (#12932) --- .../functional/dynumber/test_dynumber.py | 28 ----------------- ydb/tests/functional/dynumber/ya.make | 15 --------- ydb/tests/functional/ya.make | 1 - ydb/tests/sql/test_sql.py | 31 ++++++++++++++++++- 4 files changed, 30 insertions(+), 45 deletions(-) delete mode 100644 ydb/tests/functional/dynumber/test_dynumber.py delete mode 100644 ydb/tests/functional/dynumber/ya.make diff --git a/ydb/tests/functional/dynumber/test_dynumber.py b/ydb/tests/functional/dynumber/test_dynumber.py deleted file mode 100644 index deb742b92301..000000000000 --- a/ydb/tests/functional/dynumber/test_dynumber.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -import os -from ydb.tests.oss.ydb_sdk_import import ydb - - -def test_dynumber(): - config = ydb.DriverConfig(database=os.getenv("YDB_DATABASE"), endpoint=os.getenv("YDB_ENDPOINT")) - table_name = os.path.join("/", os.getenv("YDB_DATABASE"), "table") - with ydb.Driver(config) as driver: - driver.wait(timeout=5) - session = ydb.retry_operation_sync(lambda: driver.table_client.session().create()) - session.create_table( - table_name, - ydb.TableDescription() - .with_primary_key('key') - .with_columns( - ydb.Column('key', ydb.OptionalType(ydb.PrimitiveType.DyNumber)), - ) - ) - - for value in ["DyNumber(\".149e4\")", "DyNumber(\"15e2\")", "DyNumber(\"150e1\")", "DyNumber(\".151e4\")", "DyNumber(\"1500.1\")"]: - session.transaction().execute( - "upsert into `%s` (key ) values (%s );" % (table_name, value), - commit_tx=True, - ) - - result = session.transaction().execute("select count(*) cnt from `%s`" % table_name, commit_tx=True) - assert result[0].rows[0].cnt == 4 diff --git a/ydb/tests/functional/dynumber/ya.make b/ydb/tests/functional/dynumber/ya.make deleted file mode 100644 index 4b19c88db6b9..000000000000 --- a/ydb/tests/functional/dynumber/ya.make +++ /dev/null @@ -1,15 +0,0 @@ -PY3TEST() - -INCLUDE(${ARCADIA_ROOT}/ydb/public/tools/ydb_recipe/recipe.inc) -SIZE(MEDIUM) - -TEST_SRCS( - test_dynumber.py -) - -PEERDIR( - ydb/tests/oss/ydb_sdk_import - ydb/public/sdk/python -) - -END() diff --git a/ydb/tests/functional/ya.make b/ydb/tests/functional/ya.make index b1e60c80391a..19cce7680fd1 100644 --- a/ydb/tests/functional/ya.make +++ b/ydb/tests/functional/ya.make @@ -10,7 +10,6 @@ RECURSE( cms compatibility config - dynumber encryption hive kqp diff --git a/ydb/tests/sql/test_sql.py b/ydb/tests/sql/test_sql.py index 9a0347bcdb85..cc7501f0b21b 100644 --- a/ydb/tests/sql/test_sql.py +++ b/ydb/tests/sql/test_sql.py @@ -33,7 +33,6 @@ def teardown_class(cls): def setup(self): current_test_full_name = os.environ.get("PYTEST_CURRENT_TEST") self.table_path = "table_" + current_test_full_name.replace("::", ".").removesuffix(" (setup)") - print(self.table_path) def test_minimal_maximal_values(self): """ @@ -76,3 +75,33 @@ def test_minimal_maximal_values(self): assert len(rows) == 1, "Expected one row" assert rows[0].id == 1, "ID does not match" assert rows[0].value == value, "Value does not match" + + def test_dynumber(self): + table_name = "{}/{}".format(self.table_path, "dynamber") + self.pool.execute_with_retries( + f""" + CREATE TABLE `{table_name}` ( + id DyNumber, + PRIMARY KEY (id) + );""" + ) + + self.pool.execute_with_retries( + f""" + UPSERT INTO `{table_name}` (id) + VALUES + (DyNumber(".149e4")), + (DyNumber("15e2")), + (DyNumber("150e1")), -- same as 15e2 + (DyNumber("151e4")), + (DyNumber("1500.1")); + """ + ) + + result = self.pool.execute_with_retries( + f""" + SELECT count(*) FROM `{table_name}`; + """ + ) + + assert result[0].rows[0][0] == 4