|
| 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_inlineview_with_window_function") { |
| 19 | + sql """ |
| 20 | + drop view if exists test_table_aa; |
| 21 | + """ |
| 22 | + |
| 23 | + sql """ |
| 24 | + drop table if exists test_table_bb; |
| 25 | + """ |
| 26 | + |
| 27 | + sql """ |
| 28 | + CREATE TABLE `test_table_bb` ( |
| 29 | + `event_date` datetime NULL, |
| 30 | + `event_content` text NULL, |
| 31 | + `animal_id` bigint(20) NULL |
| 32 | + ) ENGINE=OLAP |
| 33 | + DUPLICATE KEY(`event_date`) |
| 34 | + COMMENT 'OLAP' |
| 35 | + DISTRIBUTED BY HASH(`event_date`) BUCKETS 48 |
| 36 | + PROPERTIES ( |
| 37 | + "replication_allocation" = "tag.location.default: 1", |
| 38 | + "in_memory" = "false", |
| 39 | + "storage_format" = "V2", |
| 40 | + "disable_auto_compaction" = "false" |
| 41 | + ); |
| 42 | + """ |
| 43 | + |
| 44 | + sql """ |
| 45 | + CREATE VIEW test_table_aa AS |
| 46 | + SELECT |
| 47 | + ev.event_date, |
| 48 | + ev.animal_id, |
| 49 | + get_json_int(ev.event_content, "\$.nurseOns") as nurseons |
| 50 | + FROM test_table_bb ev; |
| 51 | + """ |
| 52 | + |
| 53 | + sql """ |
| 54 | + SELECT row_number() over(PARTITION BY animal_id ORDER BY event_date DESC) rw |
| 55 | + FROM test_table_aa; |
| 56 | + """ |
| 57 | + |
| 58 | + sql """ |
| 59 | + select |
| 60 | + e1 |
| 61 | + from test_table_aa |
| 62 | + lateral view explode([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]) tmp1 as e1 |
| 63 | + where animal_id <= e1; |
| 64 | + """ |
| 65 | + |
| 66 | + sql """ |
| 67 | + drop view if exists test_table_aa; |
| 68 | + """ |
| 69 | + |
| 70 | + sql """ |
| 71 | + drop table if exists test_table_bb; |
| 72 | + """ |
| 73 | +} |
0 commit comments