-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-25768][SQL] fix constant argument expecting UDAFs #22766
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
Conversation
mgaido91
left a comment
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.
@peter-toth may you please elaborate a bit more the change in the PR description? What happened before the PR? Why? Thanks.
| } | ||
| } | ||
|
|
||
| test("constant argument expecting Hive UDF") { |
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.
may you please reference the JIRA?
| test("constant argument expecting Hive UDF") { | ||
| val testData = spark.range(10).toDF() | ||
| withTempView("inputTable") { | ||
| testData.createOrReplaceTempView("inputTable") |
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.
nit: we can move here spark.range(10)
Change-Id: If5a53df72c616d8b54662619426f5c8f34a9c0c0
| resolver.getEvaluator(parameterInfo) | ||
| } | ||
|
|
||
| private case class Mode(evaluator: GenericUDAFEvaluator, objectInspector: ObjectInspector) |
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.
evaluator and object inspector need to be initialized together
mgaido91
left a comment
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 change makes sense to me. I have just one minor comment about naming.
cc @cloud-fan @dongjoon-hyun do you think we can trigger a build?
| resolver.getEvaluator(parameterInfo) | ||
| } | ||
|
|
||
| private case class Mode(evaluator: GenericUDAFEvaluator, objectInspector: ObjectInspector) |
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.
nit: maybe we can find a better name for this class
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.
maybe just PartialEvaluator?
|
cc @cloud-fan I believe this is a regression because https://issues.apache.org/jira/browse/SPARK-18186 |
|
OK to test |
|
ok to test |
|
Test build #97547 has finished for PR 22766 at commit
|
Change-Id: I7379b21c00336e389af9b5186fac71c566699c14
|
Test build #97549 has finished for PR 22766 at commit
|
|
Retest this please. |
|
Test build #97558 has finished for PR 22766 at commit
|
| GenericUDAFEvaluator.Mode.PARTIAL1, | ||
| inputInspectors | ||
| ) | ||
| private lazy val partial1Mode = { |
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.
partial1ModeEvaluator
| GenericUDAFEvaluator.Mode.FINAL, | ||
| Array(partialResultInspector) | ||
| ) | ||
| private lazy val finalMode = { |
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.
ditto
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.
ah it's also used in final mode, then maybe HiveEvaluator is a better name than PartialEvaluator
|
Test build #97592 has finished for PR 22766 at commit
|
|
retest this please |
|
LGTM |
|
Test build #97603 has finished for PR 22766 at commit
|
## What changes were proposed in this pull request? Without this PR some UDAFs like `GenericUDAFPercentileApprox` can throw an exception because expecting a constant parameter (object inspector) as a particular argument. The exception is thrown because `toPrettySQL` call in `ResolveAliases` analyzer rule transforms a `Literal` parameter to a `PrettyAttribute` which is then transformed to an `ObjectInspector` instead of a `ConstantObjectInspector`. The exception comes from `getEvaluator` method of `GenericUDAFPercentileApprox` that actually shouldn't be called during `toPrettySQL` transformation. The reason why it is called are the non lazy fields in `HiveUDAFFunction`. This PR makes all fields of `HiveUDAFFunction` lazy. ## How was this patch tested? added new UT Closes #22766 from peter-toth/SPARK-25768. Authored-by: Peter Toth <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit f38594f) Signed-off-by: Wenchen Fan <[email protected]>
## What changes were proposed in this pull request? Without this PR some UDAFs like `GenericUDAFPercentileApprox` can throw an exception because expecting a constant parameter (object inspector) as a particular argument. The exception is thrown because `toPrettySQL` call in `ResolveAliases` analyzer rule transforms a `Literal` parameter to a `PrettyAttribute` which is then transformed to an `ObjectInspector` instead of a `ConstantObjectInspector`. The exception comes from `getEvaluator` method of `GenericUDAFPercentileApprox` that actually shouldn't be called during `toPrettySQL` transformation. The reason why it is called are the non lazy fields in `HiveUDAFFunction`. This PR makes all fields of `HiveUDAFFunction` lazy. ## How was this patch tested? added new UT Closes #22766 from peter-toth/SPARK-25768. Authored-by: Peter Toth <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit f38594f) Signed-off-by: Wenchen Fan <[email protected]>
|
thanks, merging to master/2.4/2.3! |
## What changes were proposed in this pull request? Without this PR some UDAFs like `GenericUDAFPercentileApprox` can throw an exception because expecting a constant parameter (object inspector) as a particular argument. The exception is thrown because `toPrettySQL` call in `ResolveAliases` analyzer rule transforms a `Literal` parameter to a `PrettyAttribute` which is then transformed to an `ObjectInspector` instead of a `ConstantObjectInspector`. The exception comes from `getEvaluator` method of `GenericUDAFPercentileApprox` that actually shouldn't be called during `toPrettySQL` transformation. The reason why it is called are the non lazy fields in `HiveUDAFFunction`. This PR makes all fields of `HiveUDAFFunction` lazy. ## How was this patch tested? added new UT Closes apache#22766 from peter-toth/SPARK-25768. Authored-by: Peter Toth <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
Without this PR some UDAFs like
GenericUDAFPercentileApproxcan throw an exception because expecting a constant parameter (object inspector) as a particular argument.The exception is thrown because
toPrettySQLcall inResolveAliasesanalyzer rule transforms aLiteralparameter to aPrettyAttributewhich is then transformed to anObjectInspectorinstead of aConstantObjectInspector.The exception comes from
getEvaluatormethod ofGenericUDAFPercentileApproxthat actually shouldn't be called duringtoPrettySQLtransformation. The reason why it is called are the non lazy fields inHiveUDAFFunction.This PR makes all fields of
HiveUDAFFunctionlazy.How was this patch tested?
added new UT