From 5f72d4bcc139b4d54f704245e2a02d20e25ef597 Mon Sep 17 00:00:00 2001 From: jackylee-ch Date: Mon, 13 Nov 2023 14:28:42 +0800 Subject: [PATCH] add tests --- .../execution/TestOperator.scala | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala b/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala index ca5118089755..dd00e22cd228 100644 --- a/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala +++ b/backends-velox/src/test/scala/io/glutenproject/execution/TestOperator.scala @@ -545,6 +545,39 @@ class TestOperator extends VeloxWholeStageTransformerSuite { runQueryAndCompare("SELECT c1, explode(array(c2)) FROM t") { checkOperatorMatch[GenerateExecTransformer] } + + runQueryAndCompare("SELECT c1, explode(c3) FROM (SELECT c1, array(c2) as c3 FROM t)") { + checkOperatorMatch[GenerateExecTransformer] + } + } + } + + test("Add the missing Generate validation check") { + withTable("t") { + spark + .range(10) + .selectExpr("id as c1", "id as c2") + .write + .format("parquet") + .saveAsTable("t") + + // Testing unsupported case + runQueryAndCompare("SELECT explode(from_json(cast(c1 as string),'ARRAY')) from t;") { + df => { + getExecutedPlan(df).exists(plan => plan.exists(_.isInstanceOf[GenerateExec])) + } + } + + // Testing unsupported case in case when + runQueryAndCompare( + """ + |SELECT explode(case when size(from_json(cast(c1 as string),'ARRAY')) > 0 + |then array(c1) else array(c2) end) from t; + |""".stripMargin) { + df => { + getExecutedPlan(df).exists(plan => plan.exists(_.isInstanceOf[GenerateExec])) + } + } } } }