Skip to content

Commit

Permalink
fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
shuai-xu committed Sep 4, 2024
1 parent ce4a0bb commit d773dd2
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 6 deletions.
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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from test_7096 where day = '2024-09-01'
| )) group by days, rtime, uid, owner, 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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, 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, uid, owner, 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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ class GlutenHiveSQLQueryCHSuite extends GlutenHiveSQLQuerySuiteBase {
sql("insert into test_7096 values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|select days, rtime, uid, owner, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| select day1 as days, rtime, uid, owner, 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
| )) group by days, rtime, uid, owner, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
Expand All @@ -135,13 +135,13 @@ class GlutenHiveSQLQueryCHSuite extends GlutenHiveSQLQuerySuiteBase {
sql("insert into test_7096 values ('2024-09-02', 567, 'user2', 'owner2')")
val query =
"""
|select days, rtime, uid, uid, day1
|select days, rtime, uid, owner, day1
|from (
| select day1 as days, rtime, uid, uid, day1
| select day1 as days, rtime, uid, owner, 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
| ) t1 ) t2 group by days, rtime, uid, owner, day1
|""".stripMargin
val df = sql(query)
checkAnswer(df, Seq(Row("2024-09-01", 123, "user1", "owner1", "2024-09-01")))
Expand Down
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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from test_7096 where day = '2024-09-01'
| )) group by days, rtime, uid, owner, 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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, 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, uid, owner, 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)
}
}
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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, day1
| from (
| select distinct coalesce(day, "today") as day1, rtime, uid, owner
| from test_7096 where day = '2024-09-01'
| )) group by days, rtime, uid, owner, 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, owner, day1
|from (
| select day1 as days, rtime, uid, owner, 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, uid, owner, 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 d773dd2

Please sign in to comment.