1717NULL
1818NULL
1919NULL
20- NULL
20+ NULL
21+
22+ # test variant_get with type hint (third argument)
23+ # test 1: get string field with utf8 type hint
24+ query T
25+ SELECT variant_get(json_to_variant('{"name": "Alice", "age": 30}'), 'name', 'Utf8');
26+ ----
27+ Alice
28+
29+ # test 2: get numeric field with int64 type hint
30+ query I
31+ SELECT variant_get(json_to_variant('{"name": "Bob", "age": 25}'), 'age', 'Int64');
32+ ----
33+ 25
34+
35+ # test 3: get numeric field with int32 type hint
36+ query I
37+ SELECT variant_get(json_to_variant('{"score": 100}'), 'score', 'Int32');
38+ ----
39+ 100
40+
41+ # test 4: get numeric field with float64 type hint
42+ query R
43+ SELECT variant_get(json_to_variant('{"price": 19.99}'), 'price', 'Float64');
44+ ----
45+ 19.99
46+
47+ # test 5: get boolean field with boolean type hint
48+ query B
49+ SELECT variant_get(json_to_variant('{"active": true}'), 'active', 'Boolean');
50+ ----
51+ true
52+
53+ # test 6: get null field with type hint (should return null)
54+ query T
55+ SELECT variant_get(json_to_variant('{"name": null}'), 'name', 'Utf8');
56+ ----
57+ NULL
58+
59+ # test 7: get non-existent field with type hint (should return null)
60+ query T
61+ SELECT variant_get(json_to_variant('{"name": "Charlie"}'), 'age', 'Int64');
62+ ----
63+ NULL
64+
65+ # test 8: get nested field with type hint
66+ query T
67+ SELECT variant_get(json_to_variant('{"user": {"name": "David"}}'), 'user.name', 'Utf8');
68+ ----
69+ David
70+
71+ # test 9: get array element with type hint
72+ query I
73+ SELECT variant_get(json_to_variant('{"items": [10, 20, 30]}'), 'items[1]', 'Int64');
74+ ----
75+ 20
76+
77+ # test 10: get multiple rows with type hint
78+ query I
79+ SELECT variant_get(json_to_variant(json_str), 'age', 'Int64') FROM json_data WHERE id <= 2;
80+ ----
81+ 30
82+ 25
83+
84+ # test 11: get string field from various rows with utf8 type hint
85+ query T
86+ SELECT variant_get(json_to_variant(json_str), 'name', 'Utf8') FROM json_data WHERE id <= 2;
87+ ----
88+ Alice
89+ Bob
90+
91+ # test 12: test with int16 type hint
92+ query I
93+ SELECT variant_get(json_to_variant('{"count": 5}'), 'count', 'Int16');
94+ ----
95+ 5
96+
97+ # test 13: test with int8 type hint
98+ query I
99+ SELECT variant_get(json_to_variant('{"level": 3}'), 'level', 'Int8');
100+ ----
101+ 3
102+
103+ # test 14: test with float32 type hint
104+ query R
105+ SELECT variant_get(json_to_variant('{"ratio": 0.5}'), 'ratio', 'Float32');
106+ ----
107+ 0.5
108+
109+ # test 15: test with large number and int64 type hint
110+ query I
111+ SELECT variant_get(json_to_variant('{"big_number": 9223372036854775807}'), 'big_number', 'Int64');
112+ ----
113+ 9223372036854775807
114+
115+ # test 16: test mixed types in same query - some with type hint, some without
116+ query TT
117+ SELECT
118+ variant_get(json_to_variant('{"name": "Eve", "age": 28}'), 'name', 'Utf8'),
119+ variant_pretty(variant_get(json_to_variant('{"name": "Eve", "age": 28}'), 'age'));
120+ ----
121+ Eve Int8(28)
122+
123+ # test 17: test with nested path and int64 type hint
124+ query I
125+ SELECT variant_get(json_to_variant('{"data": {"count": 42}}'), 'data.count', 'Int64');
126+ ----
127+ 42
128+
129+ # test 18: test boolean false with type hint
130+ query B
131+ SELECT variant_get(json_to_variant('{"enabled": false}'), 'enabled', 'Boolean');
132+ ----
133+ false
134+
135+ # test 19: test with decimal-like number and float64 type hint
136+ query R
137+ SELECT variant_get(json_to_variant('{"temperature": -5.5}'), 'temperature', 'Float64');
138+ ----
139+ -5.5
140+
141+ # test 20: test with zero values
142+ query I
143+ SELECT variant_get(json_to_variant('{"zero": 0}'), 'zero', 'Int64');
144+ ----
145+ 0
0 commit comments