From b2e3de8eda83892df02961306766a8011cf39947 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Mon, 27 May 2024 12:23:54 +0800 Subject: [PATCH] some refine --- .../execution/GlutenClickhouseCountDistinctSuite.scala | 4 ++-- .../org/apache/gluten/utils/PullOutProjectHelper.scala | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala index a6e315e48241f..7372740610c60 100644 --- a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala +++ b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/GlutenClickhouseCountDistinctSuite.scala @@ -215,8 +215,8 @@ class GlutenClickhouseCountDistinctSuite extends GlutenClickHouseWholeStageTrans } test("GLUTEN-5852: Fix mismatch result columns size exception related to 5618") { - val sql = "select distinct * from (select count(distinct a, b, c) from values " + - "(0, null, 1), (1, 1, 1), (2, 2, 1), (1, 2, 1) ,(2, 2, 2) as data(a,b,c) group by c) a" + val sql = "select distinct * from (select count(distinct a, b, c), 2 as r1, 2 as r2 from " + + " values (0, null, 1), (1, 1, 1), (2, 2, 1), (1, 2, 1) ,(2, 2, 2) as data(a,b,c) group by c)" compareResultsAgainstVanillaSpark(sql, true, { _ => }) } } diff --git a/gluten-core/src/main/scala/org/apache/gluten/utils/PullOutProjectHelper.scala b/gluten-core/src/main/scala/org/apache/gluten/utils/PullOutProjectHelper.scala index 9a61bda0de752..c9e93f41f92cc 100644 --- a/gluten-core/src/main/scala/org/apache/gluten/utils/PullOutProjectHelper.scala +++ b/gluten-core/src/main/scala/org/apache/gluten/utils/PullOutProjectHelper.scala @@ -61,8 +61,12 @@ trait PullOutProjectHelper { replaceBoundReference: Boolean = false): Expression = expr match { case alias: Alias => - projectExprsMap.getOrElseUpdate(alias.child.canonicalized, alias) - alias.toAttribute + alias.child match { + case _: Literal => + alias.toAttribute + case _ => + projectExprsMap.getOrElseUpdate(alias.child.canonicalized, alias).toAttribute + } case attr: Attribute => attr case e: BoundReference if !replaceBoundReference => e case other =>