Skip to content
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 LEAD/LAG failures in Spark 3.1.1 #1813

Merged
merged 6 commits into from
Feb 26, 2021

Conversation

mythrocks
Copy link
Collaborator

Fixes #999.

Fixes class-loader related errors of LEAD/LAG operators, which caused test failures like:

: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/nvidia/spark/rapids/OffsetWindowFunctionMeta.<init>(Lorg/apache/spark/sql/catalyst/expressions/OffsetWindowFunction;Lcom/nvidia/spark/rapids/RapidsConf;Lscala/Option;Lcom/nvidia/spark/rapids/ConfKeysAndIncompat;)V @11: invokespecial
Reason:
Type 'org/apache/spark/sql/catalyst/expressions/OffsetWindowFunction' (current frame, stack[1]) is not assignable to 'org/apache/spark/sql/catalyst/expressions/Expression'

Also corrects for the reversal in offset semantics for LAG() expressions in Spark 3.1.1, causing Lag.offset to be negative.

Signed-off-by: Mithun RK mythrocks@gmail.com

Fixes class-loader related failures of LEAD/LAG operators, which caused
errors like:
```
: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/nvidia/spark/rapids/OffsetWindowFunctionMeta.<init>(Lorg/apache/spark/sql/catalyst/expressions/OffsetWindowFunction;Lcom/nvidia/spark/rapids/RapidsConf;Lscala/Option;Lcom/nvidia/spark/rapids/ConfKeysAndIncompat;)V @11: invokespecial
Reason:
Type 'org/apache/spark/sql/catalyst/expressions/OffsetWindowFunction' (current frame, stack[1]) is not assignable to 'org/apache/spark/sql/catalyst/expressions/Expression'
```

Also corrects for the reversal in offset semantics for LAG() expressions
in Spark 3.1.1, causing `Lag.offset` to be negative.

Signed-off-by: Mithun RK <mythrocks@gmail.com>
@mythrocks mythrocks self-assigned this Feb 25, 2021
revans2
revans2 previously approved these changes Feb 25, 2021
@mythrocks
Copy link
Collaborator Author

At the risk of blowing this up a little, we might consider a couple of changes more:

  1. Add similarly robust offset checks in com.nvidia.spark.rapids.OffsetWindowFunctionMeta.
  2. Add a tagSelfForGpu(), and fail GPU pushdown in case the offsets in the window are not suitable for acceleration.

@revans2
Copy link
Collaborator

revans2 commented Feb 25, 2021

At the risk of blowing this up a little, we might consider a couple of changes more:

1. Add similarly robust offset checks in `com.nvidia.spark.rapids.OffsetWindowFunctionMeta`.

2. Add a `tagSelfForGpu()`, and fail GPU pushdown in case the offsets in the window are not suitable for acceleration.

Do it

@mythrocks
Copy link
Collaborator Author

mythrocks commented Feb 25, 2021

Hmm... I wonder if adding tagExprForGpu might not help.

@revans2, is there a guarantee that tagExprForGpu() will be called before OffsetWindowFunctionMeta::childExprs is evaluated? If not, the exceptions we throw when calculating the adjustedOffset would've been thrown anyway.

Copy link
Collaborator

@gerashegalov gerashegalov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

gerashegalov
gerashegalov previously approved these changes Feb 25, 2021
Signed-off-by: Mithun RK <mythrocks@gmail.com>
@mythrocks mythrocks dismissed stale reviews from gerashegalov and revans2 via 973774b February 25, 2021 21:07
@mythrocks
Copy link
Collaborator Author

If not, the exceptions we throw when calculating the adjustedOffset would've been thrown anyway.

Apologies for the delay. I have now added tagExprForGpu(), and set it up so that the expressions aren't converted for GPU on construction.

Could I please bother @gerashegalov and @revans2 to see if this is agreeable?

@revans2
Copy link
Collaborator

revans2 commented Feb 26, 2021

build

@mythrocks mythrocks merged commit 4710c3e into NVIDIA:branch-0.4 Feb 26, 2021
@mythrocks
Copy link
Collaborator Author

Thanks for the reviews, @revans2, @gerashegalov.

@sameerz sameerz added the bug Something isn't working label Mar 1, 2021
@sameerz sameerz added this to the Feb 16 - Feb 26 milestone Mar 1, 2021
nartal1 pushed a commit to nartal1/spark-rapids that referenced this pull request Jun 9, 2021
* Fix LEAD/LAG failures in Spark 3.1.1

Fixes class-loader related failures of LEAD/LAG operators, which caused
errors like:
```
: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/nvidia/spark/rapids/OffsetWindowFunctionMeta.<init>(Lorg/apache/spark/sql/catalyst/expressions/OffsetWindowFunction;Lcom/nvidia/spark/rapids/RapidsConf;Lscala/Option;Lcom/nvidia/spark/rapids/ConfKeysAndIncompat;)V @11: invokespecial
Reason:
Type 'org/apache/spark/sql/catalyst/expressions/OffsetWindowFunction' (current frame, stack[1]) is not assignable to 'org/apache/spark/sql/catalyst/expressions/Expression'
```

Also corrects for the reversal in offset semantics for LAG() expressions
in Spark 3.1.1, causing `Lag.offset` to be negative.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* Removed dead code.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* More specific error handling extracting literal offsets.

* Offset checking for pre-3.1 Spark lead/lag window functions.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* Missing whitespace.

* Added tagExprForGpu() for OffsetWindowFunctionMeta.
nartal1 pushed a commit to nartal1/spark-rapids that referenced this pull request Jun 9, 2021
* Fix LEAD/LAG failures in Spark 3.1.1

Fixes class-loader related failures of LEAD/LAG operators, which caused
errors like:
```
: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
com/nvidia/spark/rapids/OffsetWindowFunctionMeta.<init>(Lorg/apache/spark/sql/catalyst/expressions/OffsetWindowFunction;Lcom/nvidia/spark/rapids/RapidsConf;Lscala/Option;Lcom/nvidia/spark/rapids/ConfKeysAndIncompat;)V @11: invokespecial
Reason:
Type 'org/apache/spark/sql/catalyst/expressions/OffsetWindowFunction' (current frame, stack[1]) is not assignable to 'org/apache/spark/sql/catalyst/expressions/Expression'
```

Also corrects for the reversal in offset semantics for LAG() expressions
in Spark 3.1.1, causing `Lag.offset` to be negative.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* Removed dead code.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* More specific error handling extracting literal offsets.

* Offset checking for pre-3.1 Spark lead/lag window functions.

Signed-off-by: Mithun RK <mythrocks@gmail.com>

* Missing whitespace.

* Added tagExprForGpu() for OffsetWindowFunctionMeta.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] test_multi_types_window_aggs_for_rows_lead_lag fails against Spark 3.1.0
4 participants