Github user dongjoon-hyun commented on a diff in the pull request: https://github.com/apache/spark/pull/14353#discussion_r72185905 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala --- @@ -33,13 +33,24 @@ case class CreateArray(children: Seq[Expression]) extends Expression { override def foldable: Boolean = children.forall(_.foldable) - override def checkInputDataTypes(): TypeCheckResult = - TypeUtils.checkForSameTypeInputExpr(children.map(_.dataType), "function array") + override def checkInputDataTypes(): TypeCheckResult = { + if (children.map(_.dataType).forall(_.isInstanceOf[DecimalType])) { + TypeCheckResult.TypeCheckSuccess --- End diff -- And Finally, the following is the codegen result. Please see the line 29. ```scala scala> sql("explain codegen select array(0.001, 0.02)[1]").collect().foreach(println) [Found 1 WholeStageCodegen subtrees. == Subtree 1 / 1 == *Project [0.02 AS array(0.001, 0.02)[1]#75] +- Scan OneRowRelation[] Generated code: /* 001 */ public Object generate(Object[] references) { /* 002 */ return new GeneratedIterator(references); /* 003 */ } /* 004 */ /* 005 */ final class GeneratedIterator extends org.apache.spark.sql.execution.BufferedRowIterator { /* 006 */ private Object[] references; /* 007 */ private scala.collection.Iterator inputadapter_input; /* 008 */ private UnsafeRow project_result; /* 009 */ private org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder project_holder; /* 010 */ private org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter project_rowWriter; /* 011 */ /* 012 */ public GeneratedIterator(Object[] references) { /* 013 */ this.references = references; /* 014 */ } /* 015 */ /* 016 */ public void init(int index, scala.collection.Iterator inputs[]) { /* 017 */ partitionIndex = index; /* 018 */ inputadapter_input = inputs[0]; /* 019 */ project_result = new UnsafeRow(1); /* 020 */ this.project_holder = new org.apache.spark.sql.catalyst.expressions.codegen.BufferHolder(project_result, 0); /* 021 */ this.project_rowWriter = new org.apache.spark.sql.catalyst.expressions.codegen.UnsafeRowWriter(project_holder, 1); /* 022 */ } /* 023 */ /* 024 */ protected void processNext() throws java.io.IOException { /* 025 */ while (inputadapter_input.hasNext()) { /* 026 */ InternalRow inputadapter_row = (InternalRow) inputadapter_input.next(); /* 027 */ Object project_obj = ((Expression) references[0]).eval(null); /* 028 */ Decimal project_value = (Decimal) project_obj; /* 029 */ project_rowWriter.write(0, project_value, 3, 3); /* 030 */ append(project_result); /* 031 */ if (shouldStop()) return; /* 032 */ } /* 033 */ } ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org