From 9784ceef5bc6d195eb5cae4d3afb50754d596b7e Mon Sep 17 00:00:00 2001 From: lwz9103 Date: Mon, 23 Oct 2023 15:44:26 +0800 Subject: [PATCH] [GLUTEN-3489] Fix exception when in-filter contains null value --- .../execution/GlutenClickHouseTPCHParquetSuite.scala | 10 ++++++++++ cpp-ch/local-engine/Parser/SerializedPlanParser.cpp | 1 + 2 files changed, 11 insertions(+) diff --git a/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala b/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala index 4b041654a394..fe5a03adfe79 100644 --- a/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala +++ b/backends-clickhouse/src/test/scala/io/glutenproject/execution/GlutenClickHouseTPCHParquetSuite.scala @@ -2070,6 +2070,16 @@ class GlutenClickHouseTPCHParquetSuite extends GlutenClickHouseTPCHAbstractSuite compareResultsAgainstVanillaSpark(sql, true, { _ => }) } + test("test in-filter contains null value (bigint)") { + val sql = "select s_nationkey from supplier where s_nationkey in (null, 1, 2)" + compareResultsAgainstVanillaSpark(sql, true, { _ => }) + } + + test("test in-filter contains null value (string)") { + val sql = "select n_name from nation where n_name in ('CANADA', null, 'BRAZIL')" + compareResultsAgainstVanillaSpark(sql, true, { _ => }) + } + test("GLUTEN-3287: diff when divide zero") { withSQLConf( SQLConf.OPTIMIZER_EXCLUDED_RULES.key -> (ConstantFolding.ruleName + "," + NullPropagation.ruleName)) { diff --git a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp index 680dcda6c0a9..5e8ebae4804a 100644 --- a/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp +++ b/cpp-ch/local-engine/Parser/SerializedPlanParser.cpp @@ -1839,6 +1839,7 @@ const ActionsDAG::Node * SerializedPlanParser::parseExpression(ActionsDAGPtr act DB::ActionsDAG::NodeRawConstPtrs cast_args({function_node, add_column(type, true), add_column(type, Field())}); auto cast = FunctionFactory::instance().get("if", context); function_node = toFunctionNode(actions_dag, "if", cast_args); + actions_dag->addOrReplaceInOutputs(*function_node); } return function_node; }