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

[SPARK-23584][SQL] NewInstance should support interpreted execution #20778

Closed
wants to merge 2 commits into from

Conversation

maropu
Copy link
Member

@maropu maropu commented Mar 9, 2018

What changes were proposed in this pull request?

This pr supported interpreted mode for NewInstance.

How was this patch tested?

Added tests in ObjectExpressionsSuite.

@SparkQA
Copy link

SparkQA commented Mar 9, 2018

Test build #88108 has finished for PR 20778 at commit 077a0bf.

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

@@ -138,4 +154,40 @@ class ObjectExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkEvaluation(decodeUsingSerializer, null, InternalRow.fromSeq(Seq(null)))
}
}

// This is an alternative version of `checkEvaluation` to compare results
Copy link
Member Author

Choose a reason for hiding this comment

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

This function was copy from #20757, so I'll remove later.

Seq(expr.dataType.asInstanceOf[ObjectType].cls))
}
val findConstructor = (types: Seq[Seq[Class[_]]]) => {
val constructorOption = cls.getConstructors.find { c =>
Copy link
Member

Choose a reason for hiding this comment

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

Can we directly call cls.getConstructor with required Class to get it?

Copy link
Member Author

@maropu maropu Mar 9, 2018

Choose a reason for hiding this comment

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

I tried that way first, but I gave it up because the number of cls.getConstructor calls might blow up if there are many JVM type combinations in constructor arguments (e.g., constructor(java.Integer or scala.Int, java.Double or scala.Double, ....)).

Copy link
Contributor

@hvanhovell hvanhovell Apr 5, 2018

Choose a reason for hiding this comment

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

How does this compare to JVM resolution rules? The code generated version uses those.

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked the resolution rule in Class.getConstructor and I found it only supported the exact matching for parameter types (so, we couldn't handle class inheritances correctly). Then, in the latest fix, I tried to use getMatchingAccessibleConstructor in commons.lang3. It seems useful to find an acceptable constructor in a class. How about this? @hvanhovell @viirya

@SparkQA
Copy link

SparkQA commented Apr 5, 2018

Test build #88920 has finished for PR 20778 at commit 264f129.

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

@SparkQA
Copy link

SparkQA commented Apr 12, 2018

Test build #89237 has finished for PR 20778 at commit 3da287b.

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

@maropu
Copy link
Member Author

maropu commented Apr 12, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Apr 12, 2018

Test build #89240 has finished for PR 20778 at commit 3da287b.

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

@SparkQA
Copy link

SparkQA commented Apr 19, 2018

Test build #89546 has finished for PR 20778 at commit a3f0c70.

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

@maropu
Copy link
Member Author

maropu commented Apr 19, 2018

retest this please

@SparkQA
Copy link

SparkQA commented Apr 19, 2018

Test build #89565 has finished for PR 20778 at commit a3f0c70.

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

Copy link
Contributor

@hvanhovell hvanhovell left a comment

Choose a reason for hiding this comment

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

LGTM - merging to master. Thanks!

@asfgit asfgit closed this in 1b08c43 Apr 19, 2018
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.

4 participants