Skip to content

Commit

Permalink
[KYUUBI #5720] [TEST] Fix flaky test in TPCHQuerySuite
Browse files Browse the repository at this point in the history
# 🔍 Description
## Issue References 🔗

This pull request fixes #

## Describe Your Solution 🔧

TPCHQuerySuite:
- run query on tiny *** FAILED ***
  q14 (TPCHQuerySuite.scala:74)

https://github.com/apache/kyuubi/actions/runs/6891462902/job/18750551743?pr=5716

## Types of changes 🔖

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklists
## 📝 Author Self Checklist

- [ ] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project
- [ ] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

## 📝 Committer Pre-Merge Checklist

- [x] Pull request title is okay.
- [x] No license issues.
- [ ] Milestone correctly set?
- [ ] Test coverage is ok
- [ ] Assignees are selected.
- [ ] Minimum number of approvals
- [ ] No changes are requested

**Be nice. Be informative.**

Closes #5720 from cxzl25/tpch_double.

Closes #5720

0a9f3ed [sychen] round
febe647 [sychen] round
8db6325 [sychen] round
75e1699 [sychen] fix q14

Authored-by: sychen <sychen@ctrip.com>
Signed-off-by: Shaoyun Chen <csy@apache.org>
  • Loading branch information
cxzl25 committed Nov 20, 2023
1 parent 37641f3 commit 25bb7e5
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 42 deletions.
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
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
* 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)
}
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

0 comments on commit 25bb7e5

Please sign in to comment.