Skip to content

Conversation

@dilipbiswal
Copy link
Contributor

What changes were proposed in this pull request?

Invoking ArrayContains function with non nullable array type throws the following error in the code generation phase. Below is the error snippet.

Code generation of array_contains([1,2,3], 1) failed:
java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 11: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 11: Expression "isNull_0" is not an rvalue
java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 11: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 40, Column 11: Expression "isNull_0" is not an rvalue
	at com.google.common.util.concurrent.AbstractFuture$Sync.getValue(AbstractFuture.java:306)
	at com.google.common.util.concurrent.AbstractFuture$Sync.get(AbstractFuture.java:293)
	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:116)
	at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:135)
	at com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2410)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2380)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2342)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2257)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4000)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4004)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
	at org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator$.compile(CodeGenerator.scala:1305)

How was this patch tested?

Added test in CollectionExpressionSuite.

@SparkQA
Copy link

SparkQA commented Sep 2, 2018

Test build #95586 has finished for PR 22315 at commit 84b135c.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dilipbiswal
Copy link
Contributor Author

retest this please

Copy link
Contributor

@mgaido91 mgaido91 left a comment

Choose a reason for hiding this comment

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

The fix LGTM, just some minor comments to address. We might want to add a test for non-nullable types to all operators. Probably we can create an helper for this in order to avoid this issue in the future. What do you think? cc @cloud-fan @gatorsmile

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: extra newline

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: spark-xxxxx?

@SparkQA
Copy link

SparkQA commented Sep 2, 2018

Test build #95587 has finished for PR 22315 at commit 84b135c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

Choose a reason for hiding this comment

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

Could you update this part based on this comment instead of if (...) { ... } else?

@kiszk
Copy link
Member

kiszk commented Sep 2, 2018

Thank you
LGTM except one comment.

@SparkQA
Copy link

SparkQA commented Sep 2, 2018

Test build #95589 has finished for PR 22315 at commit 6f2881e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 2, 2018

Test build #95593 has finished for PR 22315 at commit 4190f42.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

Choose a reason for hiding this comment

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

How about the case right.nullable = true and
left.nullable = false AND left.dataType.asInstanceOf[ArrayType].containsNull = false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maropu This should be rejected in checkInputDataTypes(), no ?

Copy link
Member

Choose a reason for hiding this comment

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

nit: How about def checkAndSetIsNullCode(body: String) = if (nullable) {?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maropu ok..

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems too complicated to save a few duplicated code, how about

val loopBody = if (nullable) {
  s"""
    |if ($arr.isNullAt($i)) {
    |   ${ev.isNull} = true;
    |} else ...
   """
} else {
  s"""
    |if (${ctx.genEqual(right.dataType, value, getValue)}) {...
  """
}

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

Test build #95608 has finished for PR 22315 at commit c18fc08.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

Test build #95634 has finished for PR 22315 at commit 712542c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dilipbiswal
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Sep 3, 2018

Test build #95636 has finished for PR 22315 at commit 712542c.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented Sep 4, 2018

Test build #95638 has finished for PR 22315 at commit 59ddb99.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@ueshin
Copy link
Member

ueshin commented Sep 4, 2018

LGTM.

@ueshin
Copy link
Member

ueshin commented Sep 4, 2018

Thanks! merging to master.

@asfgit asfgit closed this in 8e21696 Sep 4, 2018
@gatorsmile
Copy link
Member

@dilipbiswal Could we also add the test cases for the other high-order functions, if missing?

@dilipbiswal
Copy link
Contributor Author

@gatorsmile Sure.. I will check and add.

@ueshin
Copy link
Member

ueshin commented Sep 4, 2018

@dilipbiswal Do we need to backport this to 2.3? If so, could you submit a backport pr to branch-2.3 please? Thanks!

@dilipbiswal
Copy link
Contributor Author

@ueshin Just verified in 2.3. This problem does not exist in 2.3. This is due to the fact that implementation of nullSafeCodeGen is different in 2.3 than in master. However, we are missing the test cases we added in these PRs in 2.3. Should we have the test cases checked in into the branch ? I am afraid that if we ever backported the pr that changed nullSafeCodeGen , we may introduce this bug. Please advise ..

@ueshin
Copy link
Member

ueshin commented Sep 4, 2018

@dilipbiswal Thanks for the verification! I don't think we will backport the nullSafeCodeGen to branch-2.3, but feel free to submit a pr to backport the test cases to branch-2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants