This is an automated email from the ASF dual-hosted git repository.
changchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new c7548aa005 [GLUTEN-7594] [CH] support cast const map to string (#7599)
c7548aa005 is described below
commit c7548aa005a0350b30fa987b36b9d7a5b25747f7
Author: shuai.xu <[email protected]>
AuthorDate: Fri Nov 15 15:07:27 2024 +0800
[GLUTEN-7594] [CH] support cast const map to string (#7599)
* [GLUTEN-7594] [CH] support cast const map to string
* fix test
* fix test
---
.../compatibility/GlutenClickhouseFunctionSuite.scala | 18 +++++++++++++++++-
.../local-engine/Functions/SparkFunctionMapToString.h | 8 ++++++--
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/compatibility/GlutenClickhouseFunctionSuite.scala
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/compatibility/GlutenClickhouseFunctionSuite.scala
index 2cfe935ef7..02af10657c 100644
---
a/backends-clickhouse/src/test/scala/org/apache/gluten/execution/compatibility/GlutenClickhouseFunctionSuite.scala
+++
b/backends-clickhouse/src/test/scala/org/apache/gluten/execution/compatibility/GlutenClickhouseFunctionSuite.scala
@@ -17,7 +17,7 @@
package org.apache.gluten.execution.compatibility
import org.apache.gluten.GlutenConfig
-import org.apache.gluten.execution.GlutenClickHouseTPCHAbstractSuite
+import org.apache.gluten.execution.{GlutenClickHouseTPCHAbstractSuite,
ProjectExecTransformer}
import org.apache.gluten.utils.UTSystemParameters
import org.apache.spark.SparkConf
@@ -269,6 +269,22 @@ class GlutenClickhouseFunctionSuite extends
GlutenClickHouseTPCHAbstractSuite {
}
}
+ test("GLUTEN-7594: cast const map to string") {
+ withSQLConf(
+ (
+ "spark.sql.optimizer.excludedRules",
+ "org.apache.spark.sql.catalyst.optimizer.ConstantFolding," +
+ "org.apache.spark.sql.catalyst.optimizer.NullPropagation")) {
+ runQueryAndCompare(
+ """
+ |select cast(map(1,'2') as string)
+ |""".stripMargin,
+ true,
+ false
+ )(checkGlutenOperatorMatch[ProjectExecTransformer])
+ }
+ }
+
test("GLUTEN-7550 get_json_object in IN") {
withTable("test_7550") {
sql("create table test_7550(a string) using parquet")
diff --git a/cpp-ch/local-engine/Functions/SparkFunctionMapToString.h
b/cpp-ch/local-engine/Functions/SparkFunctionMapToString.h
index 444e4542c8..3f8a0c97dc 100644
--- a/cpp-ch/local-engine/Functions/SparkFunctionMapToString.h
+++ b/cpp-ch/local-engine/Functions/SparkFunctionMapToString.h
@@ -76,7 +76,10 @@ public:
arguments[1].type->getName(), arguments[2].type->getName());
}
- return makeNullable(std::make_shared<DataTypeString>());
+ if (arguments[0].type->isNullable())
+ return makeNullable(std::make_shared<DataTypeString>());
+ else
+ return std::make_shared<DataTypeString>();
}
ColumnPtr executeImpl(const DB::ColumnsWithTypeAndName & arguments, const
DataTypePtr & result_type, size_t /*input_rows*/) const override
@@ -89,7 +92,8 @@ public:
}
const auto & col_with_type_and_name = columnGetNested(arguments[0]);
- const IColumn & col_from = *col_with_type_and_name.column;
+ const IColumn & column = *col_with_type_and_name.column;
+ const IColumn & col_from = column.isConst() ? reinterpret_cast<const
ColumnConst &>(column).getDataColumn() : column;
size_t size = col_from.size();
auto col_to = removeNullable(result_type)->createColumn();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]