|
4 | 4 | import pytest |
5 | 5 |
|
6 | 6 | from . import duckdb_serialized_expression |
| 7 | +from . import duckdb_serialized_values |
7 | 8 |
|
8 | 9 | owner_type_info = { |
9 | 10 | "Owner": 'STRUCT("DisplayName" VARCHAR,"ID" VARCHAR)', |
|
16 | 17 | } |
17 | 18 |
|
18 | 19 |
|
| 20 | +@pytest.mark.parametrize( |
| 21 | + "parser_cls,input", |
| 22 | + [ |
| 23 | + ( |
| 24 | + duckdb_serialized_values.SerializedValueType_list, |
| 25 | + { |
| 26 | + "id": "LIST", |
| 27 | + "type_info": { |
| 28 | + "type": "LIST_TYPE_INFO", |
| 29 | + "alias": "", |
| 30 | + "extension_info": None, |
| 31 | + "child_type": {"id": "INTEGER", "type_info": None}, |
| 32 | + }, |
| 33 | + }, |
| 34 | + ), |
| 35 | + ( |
| 36 | + duckdb_serialized_values.ExpressionBoundFunction, |
| 37 | + { |
| 38 | + "expression_class": "BOUND_FUNCTION", |
| 39 | + "type": "BOUND_FUNCTION", |
| 40 | + "alias": "", |
| 41 | + "query_location": 18446744073709552000, |
| 42 | + "return_type": {"id": "INTEGER", "type_info": None}, |
| 43 | + "children": [ |
| 44 | + { |
| 45 | + "expression_class": "BOUND_COLUMN_REF", |
| 46 | + "type": "BOUND_COLUMN_REF", |
| 47 | + "alias": "switches", |
| 48 | + "query_location": 18446744073709552000, |
| 49 | + "return_type": { |
| 50 | + "id": "LIST", |
| 51 | + "type_info": { |
| 52 | + "type": "LIST_TYPE_INFO", |
| 53 | + "alias": "", |
| 54 | + "extension_info": None, |
| 55 | + "child_type": {"id": "INTEGER", "type_info": None}, |
| 56 | + }, |
| 57 | + }, |
| 58 | + "binding": {"table_index": 0, "column_index": 0}, |
| 59 | + "depth": 0, |
| 60 | + }, |
| 61 | + { |
| 62 | + "expression_class": "BOUND_CONSTANT", |
| 63 | + "type": "VALUE_CONSTANT", |
| 64 | + "alias": "", |
| 65 | + "query_location": 18446744073709552000, |
| 66 | + "value": { |
| 67 | + "type": {"id": "BIGINT", "type_info": None}, |
| 68 | + "is_null": False, |
| 69 | + "value": 0, |
| 70 | + }, |
| 71 | + }, |
| 72 | + ], |
| 73 | + "name": "array_extract", |
| 74 | + "arguments": [ |
| 75 | + { |
| 76 | + "id": "LIST", |
| 77 | + "type_info": { |
| 78 | + "type": "LIST_TYPE_INFO", |
| 79 | + "alias": "", |
| 80 | + "extension_info": None, |
| 81 | + "child_type": {"id": "INTEGER", "type_info": None}, |
| 82 | + }, |
| 83 | + }, |
| 84 | + {"id": "BIGINT", "type_info": None}, |
| 85 | + ], |
| 86 | + "original_arguments": [], |
| 87 | + "catalog_name": "system", |
| 88 | + "schema_name": "main", |
| 89 | + "has_serialize": False, |
| 90 | + "is_operator": False, |
| 91 | + }, |
| 92 | + ), |
| 93 | + ], |
| 94 | +) |
| 95 | +def test_parse(parser_cls: Any, input: dict[str, Any]) -> None: |
| 96 | + parser_cls.model_validate(input) |
| 97 | + |
| 98 | + |
19 | 99 | @pytest.mark.parametrize( |
20 | 100 | "json_source,expected_sql,expected_bound_types", |
21 | 101 | [ |
|
0 commit comments