maropu commented on a change in pull request #25717: [WIP][SPARK-29013][SQL] Structurally equivalent subexpression elimination URL: https://github.com/apache/spark/pull/25717#discussion_r321998484
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/BoundAttribute.scala ########## @@ -65,6 +65,40 @@ case class BoundReference(ordinal: Int, dataType: DataType, nullable: Boolean) } } +/** + * This bound reference points to a parameterized slot in an input tuple. It is used in + * common sub-expression elimination. When some common sub-expressions have same structural + * but different slots of input tuple, we replace `BoundReference` with this parameterized + * version. The slot position is parameterized and is given at runtime. + */ +case class ParameterizedBoundReference(parameter: String, dataType: DataType, nullable: Boolean) + extends LeafExpression { + + override def toString: String = s"input[$parameter, ${dataType.simpleString}, $nullable]" + + override def eval(input: InternalRow): Any = { + throw new UnsupportedOperationException( + "ParameterizedBoundReference does not implement eval") + } + + override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { + assert(ctx.currentVars == null && ctx.INPUT_ROW != null, + "ParameterizedBoundReference can not be used in whole-stage codegen yet.") Review comment: Any barrier to support the whole-stage codegen case? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org