Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Fix flaky test in TPCHQuerySuite #5720

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

-2130215201
-1796738616
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
select
l_returnflag,
l_linestatus,
sum(l_quantity) as sum_qty,
sum(l_extendedprice) as sum_base_price,
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
avg(l_quantity) as avg_qty,
avg(l_extendedprice) as avg_price,
avg(l_discount) as avg_disc,
round(sum(l_quantity), 2) as sum_qty,
round(sum(l_extendedprice), 2) as sum_base_price,
round(sum(l_extendedprice * (1 - l_discount)), 2) as sum_disc_price,
round(sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)), 2) as sum_charge,
round(avg(l_quantity), 2) as avg_qty,
round(avg(l_extendedprice), 2) as avg_price,
round(avg(l_discount), 2) as avg_disc,
count(*) as count_order
from
lineitem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

-4090660469
-730770831
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
select
c_custkey,
c_name,
sum(l_extendedprice * (1 - l_discount)) as revenue,
round(sum(l_extendedprice * (1 - l_discount)), 1) as revenue,
c_acctbal,
n_name,
c_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

47333415
799857942
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
-- using default substitutions

select
100.00 * sum(case
round(100.00 * sum(case
when p_type like 'PROMO%'
then l_extendedprice * (1 - l_discount)
else 0
end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue
end) / sum(l_extendedprice * (1 - l_discount)), 2) as promo_revenue
Copy link
Contributor Author

@cxzl25 cxzl25 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GA

query q14 result: List([15.486545812284065])

Local Mac

query q14 result: List([15.486545812284069])

PR

query q14 result: List([15.49])

from
lineitem,
part
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

-2021679095
-1401614325
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ select
s_name,
s_address,
s_phone,
total_revenue
round(total_revenue, 2) as total_revenue
from
supplier,
revenue0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

2111900859
2123615405
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
select
cntrycode,
count(*) as numcust,
sum(c_acctbal) as totacctbal
round(sum(c_acctbal), 2) as totacctbal
from
(
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

3717321142
-2755325540
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

select
n_name,
sum(l_extendedprice * (1 - l_discount)) as revenue
round(sum(l_extendedprice * (1 - l_discount)), 2) as revenue
from
customer,
orders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

2062248569
223845550
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-- using default substitutions

select
sum(l_extendedprice * l_discount) as revenue
round(sum(l_extendedprice * l_discount), 2) as revenue
from
lineitem
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

-1955579146
-95255706
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ select
supp_nation,
cust_nation,
l_year,
sum(volume) as revenue
round(sum(volume), 2) as revenue
from
(
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* limitations under the License.
*/

10861514367
-12715678387
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
select
nation,
o_year,
sum(amount) as sum_profit
round(sum(amount), 2) as sum_profit
from
(
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ import org.apache.kyuubi.spark.connector.common.LocalSparkSession.withSparkSessi
/**
* To run this test suite:
* {{{
* KYUUBI_UPDATE=0 dev/gen/gen_tpcdh_queries.sh
* KYUUBI_UPDATE=0 dev/gen/gen_tpch_queries.sh
* }}}
*
* To re-generate golden files for this suite:
* {{{
* dev/gen/gen_tpcdh_queries.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

* dev/gen/gen_tpch_queries.sh
* }}}
*/
@Slow
class TPCHQuerySuite extends KyuubiFunSuite {

val queries: Set[String] = (1 to 22).map(i => s"q$i").toSet
val queries: List[String] = (1 to 22).map(i => s"q$i").toList

test("run query on tiny") {
val viewSuffix = "view"
Expand All @@ -59,20 +59,15 @@ class TPCHQuerySuite extends KyuubiFunSuite {
in.close()
queryName -> queryContent
}.foreach { case (name, sql) =>
try {
val result = spark.sql(sql).collect()
val schema = spark.sql(sql).schema
val schemaDDL = LICENSE_HEADER + schema.toDDL + "\n"
spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
val sumHashResult = LICENSE_HEADER + spark.sql(
s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0) + "\n"
val tuple = generateGoldenFiles("kyuubi/tpch", name, schemaDDL, sumHashResult)
assert(schemaDDL == tuple._1)
assert(sumHashResult == tuple._2)
} catch {
case cause: Throwable =>
fail(name, cause)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot display the comparison results of assert

}
val result = spark.sql(sql).collect()
val schema = spark.sql(sql).schema
val schemaDDL = LICENSE_HEADER + schema.toDDL + "\n"
spark.createDataFrame(result.toList.asJava, schema).createTempView(s"$name$viewSuffix")
val sumHashResult = LICENSE_HEADER + spark.sql(
s"select sum(hash(*)) from $name$viewSuffix").collect().head.get(0) + "\n"
val tuple = generateGoldenFiles("kyuubi/tpch", name, schemaDDL, sumHashResult)
assert(schemaDDL == tuple._1, s"query $name schema not match")
assert(sumHashResult == tuple._2, s"query $name result not match")
}
}
}
Expand Down
Loading