diff options
| author | Grigorii Papashvili <[email protected]> | 2024-06-18 18:11:36 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-06-18 18:11:36 +0300 |
| commit | 2734f01bb830e999df7bdecd2c6ad1b002c6dd67 (patch) | |
| tree | eee683612c7d33962a2d7122bcd80e60a9e1b05d | |
| parent | 0e8e52f6fb2741bd326fee33cf2ab19d782138b5 (diff) | |
FQ: YDB: fix Json test (#5670)
3 files changed, 28 insertions, 10 deletions
diff --git a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/init/01_basic.sh b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/init/01_basic.sh index 8d2b77b867c..259f2ebcbfb 100755 --- a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/init/01_basic.sh +++ b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/init/01_basic.sh @@ -150,6 +150,18 @@ set -ex (1, DATE("2024-01-01") - DATE("2023-01-01")), (2, DATE("2022-01-01") - DATE("2023-01-01")); COMMIT; + + CREATE TABLE json_NATIVE (col_00_id Int32 NOT NULL, col_01_json Json NOT NULL, col_02_json_nullable Json, PRIMARY KEY (col_00_id)); + COMMIT; + INSERT INTO json_NATIVE (col_00_id, col_01_json, col_02_json_nullable) VALUES + ( + 1, + @@{ "friends" : [{"name": "James Holden","age": 35},{"name": "Naomi Nagata","age": 30}]}@@, + CAST(@@{ "friends" : [{"name": "James Holden","age": 35},{"name": "Naomi Nagata","age": 30}]}@@ AS Json) + ), + (2, @@{ "TODO": "unicode" }@@, CAST(@@{ "TODO": "unicode" }@@AS Json)), + (3, @@{ }@@, NULL); + COMMIT; ' echo $(date +"%T.%6N") "SUCCESS" diff --git a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/select_positive.py b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/select_positive.py index 8414812dda5..0141be248bb 100644 --- a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/select_positive.py +++ b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/select_positive.py @@ -504,12 +504,17 @@ class Factory: schema = Schema( columns=ColumnList( Column( - name='col_json', + name='col_00_id', + ydb_type=makeYdbTypeFromTypeID(Type.INT32), + data_source_type=DataSourceType(ydb=types_ydb.Int32().to_non_nullable()), + ), + Column( + name='col_01_json', ydb_type=makeYdbTypeFromTypeID(Type.JSON), data_source_type=DataSourceType(ydb=types_ydb.Json().to_non_nullable()), ), Column( - name='col_json', + name='col_02_json_nullable', ydb_type=makeYdbTypeFromTypeID(Type.JSON), data_source_type=DataSourceType(ydb=types_ydb.Json()), ), @@ -520,20 +525,21 @@ class Factory: data_in = [ [ + 1, '{ "friends": [{"name": "James Holden","age": 35},{"name": "Naomi Nagata","age": 30}]}', '{ "friends": [{"name": "James Holden","age": 35},{"name": "Naomi Nagata","age": 30}]}', ], - ['{ "TODO" : "unicode" }', '{ "TODO" : "unicode" }'], - [None, None], + [2, '{ "TODO" : "unicode" }', '{ "TODO" : "unicode" }'], + [3, '{}', None], ] data_out_1 = [ - ['{"age":35,"name":"James Holden"}', '{"age":35,"name":"James Holden"}'], - [None, None], - [None, None], + ['{"age":35,"name":"James Holden"}'], + [None], + [None], ] - data_source_kind = EDataSourceKind.POSTGRESQL + data_source_kind = EDataSourceKind.YDB test_case_name = 'json' @@ -543,7 +549,7 @@ class Factory: data_in=data_in, data_out_=data_out_1, protocol=EProtocol.NATIVE, - select_what=SelectWhat(SelectWhat.Item(name='JSON_QUERY(col_json, "$.friends[0]")', kind='expr')), + select_what=SelectWhat(SelectWhat.Item(name='JSON_QUERY(col_01_json, "$.friends[0]")', kind='expr')), select_where=None, data_source_kind=data_source_kind, pragmas=dict(), diff --git a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/test.py b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/test.py index baded7a752d..de4fcb6d91b 100644 --- a/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/test.py +++ b/ydb/library/yql/providers/generic/connector/tests/datasource/ydb/test.py @@ -39,7 +39,6 @@ class OneTimeWaiter: start = datetime.now() timeout = 60 - # timeout = 120 # timeout = 600 while (datetime.now() - start).total_seconds() < timeout: self.actual_tables = set(self.docker_compose_helper.list_ydb_tables()) @@ -69,6 +68,7 @@ one_time_waiter = OneTimeWaiter( "count_NATIVE", "pushdown_NATIVE", "unsupported_types_NATIVE", + "json_NATIVE", ] ) |
