From 3233efc76ba1578b5dc3c3a5bf39799e540c6ff6 Mon Sep 17 00:00:00 2001 From: jackylee-ch Date: Mon, 18 Jul 2022 19:56:39 +0800 Subject: [PATCH] fix: problem with partitioning with literal in window function --- .../oap/execution/ColumnarWindowExec.scala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/native-sql-engine/core/src/main/scala/com/intel/oap/execution/ColumnarWindowExec.scala b/native-sql-engine/core/src/main/scala/com/intel/oap/execution/ColumnarWindowExec.scala index 0ac0a7eb8..93b9a9903 100644 --- a/native-sql-engine/core/src/main/scala/com/intel/oap/execution/ColumnarWindowExec.scala +++ b/native-sql-engine/core/src/main/scala/com/intel/oap/execution/ColumnarWindowExec.scala @@ -257,19 +257,27 @@ case class ColumnarWindowExec(windowExpression: Seq[NamedExpression], Some(TreeBuilder.makeField( Field.nullable(a.name, CodeGeneration.getResultType(a.dataType)))) - case c: Cast => + case c: Cast if c.child.isInstanceOf[AttributeReference] => Some(TreeBuilder.makeField( Field.nullable(c.child.asInstanceOf[AttributeReference].name, - CodeGeneration.getResultType(c.dataType)) - )) - case _: Literal => + CodeGeneration.getResultType(c.dataType)))) + case _: Cast | _ : Literal => None case _ => throw new IllegalStateException() }.toList.asJava, NoneType.NONE_TYPE) } - val groupingExpressions = partitionSpec.map(e => e.asInstanceOf[AttributeReference]) + val groupingExpressions: Seq[AttributeReference] = partitionSpec.map{ + case a: AttributeReference => + a + case c: Cast if c.child.isInstanceOf[AttributeReference] => + c.child.asInstanceOf[AttributeReference] + case _: Cast | _ : Literal => + null + case _ => + throw new IllegalStateException() + }.filter(_ != null) val gPartitionSpec = TreeBuilder.makeFunction("partitionSpec", groupingExpressions.map(e => TreeBuilder.makeField(