Skip to content

Commit 44fa16d

Browse files
hubgetermorningman
authored andcommitted
fix lfs
1 parent 737c72a commit 44fa16d

File tree

4 files changed

+174
-145
lines changed

4 files changed

+174
-145
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
import groovy.json.JsonSlurper
19+
20+
suite("test_parquet_join_runtime_filter", "p0,external,hive,external_docker,external_docker_hive") {
21+
22+
def getProfileList = {
23+
def dst = 'http://' + context.config.feHttpAddress
24+
def conn = new URL(dst + "/rest/v1/query_profile").openConnection()
25+
conn.setRequestMethod("GET")
26+
def encoding = Base64.getEncoder().encodeToString((context.config.feHttpUser + ":" +
27+
(context.config.feHttpPassword == null ? "" : context.config.feHttpPassword)).getBytes("UTF-8"))
28+
conn.setRequestProperty("Authorization", "Basic ${encoding}")
29+
return conn.getInputStream().getText()
30+
}
31+
32+
def getProfile = { id ->
33+
def dst = 'http://' + context.config.feHttpAddress
34+
def conn = new URL(dst + "/api/profile/text/?query_id=$id").openConnection()
35+
conn.setRequestMethod("GET")
36+
def encoding = Base64.getEncoder().encodeToString((context.config.feHttpUser + ":" +
37+
(context.config.feHttpPassword == null ? "" : context.config.feHttpPassword)).getBytes("UTF-8"))
38+
conn.setRequestProperty("Authorization", "Basic ${encoding}")
39+
return conn.getInputStream().getText()
40+
}
41+
42+
43+
def extractFilteredGroupsValue = { String profileText ->
44+
def values = (profileText =~ /FilteredGroups:\s*(\d+)/).collect { it[1].toLong() }
45+
return values.sort { a, b -> b <=> a }
46+
}
47+
48+
def getProfileWithToken = { token ->
49+
String profileId = ""
50+
int attempts = 0
51+
while (attempts < 10 && (profileId == null || profileId == "")) {
52+
List profileData = new JsonSlurper().parseText(getProfileList()).data.rows
53+
for (def profileItem in profileData) {
54+
if (profileItem["Sql Statement"].toString().contains(token)) {
55+
profileId = profileItem["Profile ID"].toString()
56+
break
57+
}
58+
}
59+
if (profileId == null || profileId == "") {
60+
Thread.sleep(300)
61+
}
62+
attempts++
63+
}
64+
assertTrue(profileId != null && profileId != "")
65+
Thread.sleep(800)
66+
return getProfile(profileId).toString()
67+
}
68+
// session vars
69+
sql "unset variable all;"
70+
sql "set profile_level=2;"
71+
sql "set enable_profile=true;"
72+
73+
74+
String enabled = context.config.otherConfigs.get("enableHiveTest")
75+
if (!"true".equalsIgnoreCase(enabled)) {
76+
return;
77+
}
78+
for (String hivePrefix : ["hive2"]) {
79+
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
80+
String hmsPort = context.config.otherConfigs.get(hivePrefix + "HmsPort")
81+
String catalog_name = "test_parquet_join_runtime_filter"
82+
83+
sql """drop catalog if exists ${catalog_name};"""
84+
sql """
85+
create catalog if not exists ${catalog_name} properties (
86+
'type'='hms',
87+
'hadoop.username' = 'hadoop',
88+
'hive.metastore.uris' = 'thrift://${externalEnvIp}:${hmsPort}'
89+
);
90+
"""
91+
logger.info("catalog " + catalog_name + " created")
92+
sql """switch ${catalog_name};"""
93+
logger.info("switched to catalog " + catalog_name)
94+
95+
sql """ use `default` """
96+
97+
98+
for (int wait_time : [0, 10, 100]) {
99+
sql """ set runtime_filter_wait_time_ms = ${wait_time}; """
100+
101+
def f1 = {
102+
def t1 = UUID.randomUUID().toString()
103+
def sql_result = sql """
104+
select *, "${t1}" from fact_big as a join dim_small as b on a.k = b.k where b.c1 = 5
105+
"""
106+
def filter_result = extractFilteredGroupsValue(getProfileWithToken(t1));
107+
logger.info("sql_result = ${sql_result}");
108+
logger.info("filter_result = ${filter_result}");
109+
110+
assertTrue(filter_result.size() == 2)
111+
assertTrue(filter_result[0] > 40)
112+
}
113+
114+
115+
116+
def f2 = {
117+
def t1 = UUID.randomUUID().toString()
118+
def sql_result = sql """
119+
select *, "${t1}" from fact_big as a join dim_small as b on a.k = b.k where b.c1 in (1,2)
120+
"""
121+
def filter_result = extractFilteredGroupsValue(getProfileWithToken(t1));
122+
logger.info("sql_result = ${sql_result}");
123+
logger.info("filter_result = ${filter_result}");
124+
125+
assertTrue(filter_result.size() == 2)
126+
assertTrue(filter_result[0] > 30)
127+
}
128+
129+
130+
131+
132+
def f3 = {
133+
def t1 = UUID.randomUUID().toString()
134+
def sql_result = sql """
135+
select *, "${t1}" from fact_big as a join dim_small as b on a.k = b.k where b.c1 < 3
136+
"""
137+
def filter_result = extractFilteredGroupsValue(getProfileWithToken(t1));
138+
logger.info("sql_result = ${sql_result}");
139+
logger.info("filter_result = ${filter_result}");
140+
141+
assertTrue(filter_result.size() == 2)
142+
assertTrue(filter_result[0] > 30)
143+
}
144+
145+
146+
147+
def f4 = {
148+
def t1 = UUID.randomUUID().toString()
149+
def sql_result = sql """
150+
select *, "${t1}" from fact_big as a join dim_small as b on a.k = b.k where b.c2 >= 50
151+
"""
152+
def filter_result = extractFilteredGroupsValue(getProfileWithToken(t1));
153+
logger.info("sql_result = ${sql_result}");
154+
logger.info("filter_result = ${filter_result}");
155+
156+
assertTrue(filter_result.size() == 2)
157+
assertTrue(filter_result[0] > 40)
158+
}
159+
160+
161+
f1()
162+
f2()
163+
f3()
164+
f4()
165+
}
166+
167+
sql """drop catalog ${catalog_name};"""
168+
}
169+
170+
171+
172+
173+
174+
}

regression-test/suites/external_table_p0/test_parquet_join_runtime_filter.groovy

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)