|
| 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_outer_join_with_subquery") { |
| 19 | + sql """ |
| 20 | + drop table if exists test_outer_join_with_subquery_outerjoin_A; |
| 21 | + """ |
| 22 | + |
| 23 | + sql """ |
| 24 | + drop table if exists test_outer_join_with_subquery_outerjoin_B; |
| 25 | + """ |
| 26 | + |
| 27 | + sql """ |
| 28 | + create table test_outer_join_with_subquery_outerjoin_A ( a int not null ) |
| 29 | + ENGINE=OLAP |
| 30 | + DISTRIBUTED BY HASH(a) BUCKETS 1 |
| 31 | + PROPERTIES ( |
| 32 | + "replication_allocation" = "tag.location.default: 1", |
| 33 | + "in_memory" = "false", |
| 34 | + "storage_format" = "V2" |
| 35 | + ); |
| 36 | + """ |
| 37 | + |
| 38 | + sql """ |
| 39 | + create table test_outer_join_with_subquery_outerjoin_B ( a int not null ) |
| 40 | + ENGINE=OLAP |
| 41 | + DISTRIBUTED BY HASH(a) BUCKETS 1 |
| 42 | + PROPERTIES ( |
| 43 | + "replication_allocation" = "tag.location.default: 1", |
| 44 | + "in_memory" = "false", |
| 45 | + "storage_format" = "V2" |
| 46 | + ); |
| 47 | + """ |
| 48 | + |
| 49 | + sql """ |
| 50 | + insert into test_outer_join_with_subquery_outerjoin_A values( 1 ); |
| 51 | + """ |
| 52 | + |
| 53 | + sql """ |
| 54 | + insert into test_outer_join_with_subquery_outerjoin_B values( 1 ); |
| 55 | + """ |
| 56 | + |
| 57 | + qt_select """ |
| 58 | + select |
| 59 | + subq_1.c1 |
| 60 | + from |
| 61 | + ( |
| 62 | + select |
| 63 | + case |
| 64 | + when test_outer_join_with_subquery_outerjoin_A.a is NULL then test_outer_join_with_subquery_outerjoin_A.a |
| 65 | + else test_outer_join_with_subquery_outerjoin_A.a |
| 66 | + end as c1 |
| 67 | + from |
| 68 | + test_outer_join_with_subquery_outerjoin_A |
| 69 | + ) as subq_1 |
| 70 | + full join ( |
| 71 | + select |
| 72 | + case |
| 73 | + when test_outer_join_with_subquery_outerjoin_B.a is NULL then test_outer_join_with_subquery_outerjoin_B.a |
| 74 | + else test_outer_join_with_subquery_outerjoin_B.a |
| 75 | + end as c2 |
| 76 | + from |
| 77 | + test_outer_join_with_subquery_outerjoin_B |
| 78 | + ) as subq_2 on (subq_1.c1 = subq_2.c2); |
| 79 | + """ |
| 80 | + |
| 81 | + sql """ |
| 82 | + drop table if exists test_outer_join_with_subquery_outerjoin_A; |
| 83 | + """ |
| 84 | + |
| 85 | + sql """ |
| 86 | + drop table if exists test_outer_join_with_subquery_outerjoin_B; |
| 87 | + """ |
| 88 | +} |
0 commit comments