Skip to content

Commit

Permalink
move case to hive
Browse files Browse the repository at this point in the history
  • Loading branch information
shuai-xu committed Sep 4, 2024
1 parent c78b898 commit ce4a0bb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,4 @@ class GlutenSQLAggregateFunctionSuite extends GlutenSQLTestsTrait {
checkAnswer(df, Seq(Row(3, 5)))
assert(getExecutedPlan(df).count(_.isInstanceOf[HashAggregateExecBaseTransformer]) == 4)
}

testGluten("GLUTEN-7096: Same names in group by may cause exception") {
sql("create table if not exists user (day string, rtime int, uid string, owner string)")
sql("insert into user values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into user values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into user values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from user where day = '2024-09-01'
| )) group by days, rtime, guest_uid, owner_uid, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
sql("drop table if exists user")
}

testGluten("GLUTEN-7096: Same names with different qualifier in group by may cause exception") {
sql("create table if not exists user (day string, rtime int, uid string, owner string)")
sql("insert into user values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into user values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into user values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from user where day = '2024-09-01'
| ) t1 ) t2 group by days, rtime, guest_uid, owner_uid, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
sql("drop table if exists user")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,49 @@ class GlutenHiveSQLQueryCHSuite extends GlutenHiveSQLQuerySuiteBase {
purge = false)
}

testGluten("GLUTEN-7096: Same names in group by may cause exception") {
sql("create table if not exists test_7096 (day string, rtime int, uid string, owner string)")
sql("insert into test_7096 values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into test_7096 values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into test_7096 values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from test_7096 where day = '2024-09-01'
| )) group by days, rtime, guest_uid, owner_uid, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
spark.sessionState.catalog.dropTable(
TableIdentifier("test_7096"),
ignoreIfNotExists = true,
purge = false)
}

testGluten("GLUTEN-7096: Same names with different qualifier in group by may cause exception") {
sql("create table if not exists test_7096 (day string, rtime int, uid string, owner string)")
sql("insert into test_7096 values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into test_7096 values ('2024-09-01', 123, 'user1', 'owner1')")
sql("insert into test_7096 values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from test_7096 where day = '2024-09-01'
| ) t1 ) t2 group by days, rtime, guest_uid, owner_uid, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
spark.sessionState.catalog.dropTable(
TableIdentifier("test_7096"),
ignoreIfNotExists = true,
purge = false)
}
}

0 comments on commit ce4a0bb

Please sign in to comment.