-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix GpuCreateNamedStruct not serializable issue #2442
Changes from 3 commits
c3e07f0
b7d2e26
bfe48e4
4034015
0ffc9a8
d194afe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
package org.apache.spark.sql.rapids | ||
|
||
import ai.rapids.cudf.{ColumnVector, DType} | ||
import com.nvidia.spark.rapids.{GpuColumnVector, GpuExpression, GpuExpressionsUtils} | ||
import com.nvidia.spark.rapids.{GpuAlias, GpuColumnVector, GpuExpression, GpuExpressionsUtils, GpuLiteral} | ||
import com.nvidia.spark.rapids.RapidsPluginImplicits.ReallyAGpuExpression | ||
|
||
import org.apache.spark.sql.catalyst.analysis.{TypeCheckResult, TypeCoercion} | ||
|
@@ -87,8 +87,17 @@ case class GpuCreateNamedStruct(children: Seq[Expression]) extends GpuExpression | |
case Seq(name, value) => (name, value) | ||
}.toList.unzip | ||
|
||
// Names will be serialized before Spark scheduling, and the returned type GpuScalar | ||
// from GpuLiteral.columnarEval(null) can't be serializable, which causes | ||
// `org.apache.spark.SparkException: Task not serializable` issue. | ||
// | ||
// And on the other hand, the calling for columnarEval(null) in the driver side is | ||
// dangerous for GpuExpressions, we'll have to pull it apart manually. | ||
private lazy val names = nameExprs.map { | ||
case g: GpuExpression => g.columnarEval(null) | ||
case gl: GpuLiteral => gl.value | ||
case GpuAlias(gl: GpuLiteral, _) => gl.value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically Alias can nest arbitrarily, so I think we'd want to match on the result of calling something like what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, Good suggestion, from the safe side, I added the extractGpulit for this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
case ge: GpuExpression => | ||
throw new IllegalStateException(s"Unexpected GPU expression $ge") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have tried to make it so the Literal is wrapped in an Alias, which should totally be valid, but I have not been able to make it happen with the public spark APIs. If we are going to throw an exception on something we don't expect, then we should be absolutely positive that we got what we expected, and all of the default literal checks being use allow for an alias. So either still do the eval and then pull the name out of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We can't do this because this is happening on the driver side, correct? That's one of the drawbacks of the recent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with Jason, and the new commit has added GpuAlias case. BTW, I see the name check has been limited to literal, Do we really add the GpuAlias case? object CreateNamedStructCheck extends ExprChecks {
val nameSig: TypeSig = TypeSig.lit(TypeEnum.STRING) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If a But I am a little confused. Could we call the |
||
case e => e.eval(EmptyRow) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for this change is not clear. Could we get a comment to explain why this is happening so no one accidentally changes it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done