Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/6479#discussion_r31687550
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateMutableProjection.scala
---
@@ -36,41 +36,60 @@ object GenerateMutableProjection extends
CodeGenerator[Seq[Expression], () => Mu
in.map(BindReferences.bindReference(_, inputSchema))
protected def create(expressions: Seq[Expression]): (() =>
MutableProjection) = {
- val projectionCode = expressions.zipWithIndex.flatMap { case (e, i) =>
- val evaluationCode = expressionEvaluator(e)
-
- evaluationCode.code :+
- q"""
- if(${evaluationCode.nullTerm})
- mutableRow.setNullAt($i)
- else
- ${setColumn(mutableRowName, e.dataType, i,
evaluationCode.primitiveTerm)}
- """
- }
+ val ctx = newCodeGenContext()
+ val projectionCode = expressions.zipWithIndex.map { case (e, i) =>
+ val evaluationCode = expressionEvaluator(e, ctx)
+ evaluationCode.code +
+ s"""
+ if(${evaluationCode.nullTerm})
+ mutableRow.setNullAt($i);
+ else
+ ${setColumn("mutableRow", e.dataType, i,
evaluationCode.primitiveTerm)};
+ """
+ }.mkString("\n")
+ val code = s"""
+ import org.apache.spark.sql.Row;
+
+ public SpecificProjection generate($exprType[] expr) {
+ return new SpecificProjection(expr);
+ }
+
+ class SpecificProjection extends ${typeOf[BaseMutableProjection]} {
- val code =
- q"""
- () => { new $mutableProjectionType {
+ $exprType[] expressions = null;
--- End diff --
This could be `final`, but probably no major reason to set it final.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]