|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +suite("test_variant_array_subscript_cir_20316", "p0") { |
| 19 | + sql "set default_variant_enable_nested_group = false" |
| 20 | + sql "set default_variant_max_subcolumns_count = 100" |
| 21 | + |
| 22 | + sql "DROP TABLE IF EXISTS test_variant_array_subscript_cir_20316" |
| 23 | + sql """ |
| 24 | + CREATE TABLE test_variant_array_subscript_cir_20316 ( |
| 25 | + id BIGINT, |
| 26 | + v VARIANT |
| 27 | + ) ENGINE=OLAP |
| 28 | + DUPLICATE KEY(id) |
| 29 | + DISTRIBUTED BY HASH(id) BUCKETS 1 |
| 30 | + PROPERTIES ( |
| 31 | + "replication_allocation" = "tag.location.default: 1", |
| 32 | + "disable_auto_compaction" = "true" |
| 33 | + ) |
| 34 | + """ |
| 35 | + |
| 36 | + sql """ |
| 37 | + INSERT INTO test_variant_array_subscript_cir_20316 VALUES |
| 38 | + (1, '{"items":{"type":["e2e_QC","platform_QC"]}}') |
| 39 | + """ |
| 40 | + sql "sync" |
| 41 | + |
| 42 | + test { |
| 43 | + sql """ |
| 44 | + SELECT id, |
| 45 | + CAST(v['items']['type'] AS ARRAY<STRING>)[0], |
| 46 | + CAST(v['items']['type'] AS ARRAY<STRING>)[1], |
| 47 | + CAST(v['items']['type'] AS ARRAY<STRING>)[2], |
| 48 | + element_at(CAST(v['items']['type'] AS ARRAY<STRING>), 1), |
| 49 | + element_at(CAST(v['items']['type'] AS ARRAY<STRING>), 2) |
| 50 | + FROM test_variant_array_subscript_cir_20316 |
| 51 | + ORDER BY id |
| 52 | + """ |
| 53 | + result([[1L, null, "e2e_QC", "platform_QC", "e2e_QC", "platform_QC"]]) |
| 54 | + } |
| 55 | +} |
0 commit comments