forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_func_generator.py
More file actions
58 lines (52 loc) · 2.13 KB
/
Copy patharray_func_generator.py
File metadata and controls
58 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
def generate_test_queries(func_name, lambda_name):
data_types = {
'Double': 'kadbl',
'Float': 'kafloat',
'LargeInt': 'kalint',
'BigInt': 'kabint',
'SmallInt': 'kasint',
'Integer': 'kaint',
'TinyInt': 'katint',
'DecimalV3': 'kadcml'
}
table_names = {
'Double': 'fn_test',
'Float': 'fn_test',
'LargeInt': 'fn_test',
'BigInt': 'fn_test',
'SmallInt': 'fn_test',
'Integer': 'fn_test',
'TinyInt': 'fn_test',
'DecimalV3': 'fn_test'
}
queries = []
for data_type, column_name in data_types.items():
query = f'order_qt_sql_{func_name}_{data_type} "select {func_name}({lambda_name}, {column_name}) from {table_names[data_type]}"'
query_not_null = f'order_qt_sql_{func_name}_{data_type}_notnull "select {func_name}({lambda_name}, {column_name}) from {table_names[data_type]}_not_nullable"'
queries.append(query)
queries.append(query_not_null)
return queries
# 调用函数生成测试查询
func_name_set = {"array_map", "array_filter", "array_exists", "array_count", "array_last_index", "array_first_index", "array_sortby"}
queries = []
for func_name in func_name_set:
queries.append(f"// test {func_name}")
queries.extend(generate_test_queries(func_name, "x -> x > 1"))
for query in queries:
print(query)