Skip to content

Conversation

@viirya
Copy link
Member

@viirya viirya commented Apr 5, 2018

What changes were proposed in this pull request?

Currently, interpreted execution of LambdaVariable just uses InternalRow.get to access element. We should use specified accessors if possible.

How was this patch tested?

Added test.

@viirya
Copy link
Member Author

viirya commented Apr 5, 2018

cc @hvanhovell

@SparkQA
Copy link

SparkQA commented Apr 5, 2018

Test build #88926 has finished for PR 20981 at commit 35539be.

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

@viirya
Copy link
Member Author

viirya commented Apr 5, 2018

retest this please.

dataType: DataType,
nullable: Boolean = true) extends LeafExpression with NonSQLExpression {

private lazy val accessor: InternalRow => Any = dataType match {
Copy link
Contributor

Choose a reason for hiding this comment

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

We could make this a bit more generic and also use this for BoundReference.

}

val acceptedTypes = elementTypes ++ arrayTypes ++ mapTypes ++ structTypes
val random = new Random()
Copy link
Contributor

Choose a reason for hiding this comment

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

Please set a seed or use withClue() otherwise it will be very annoying to debug these when something goes south.

@hvanhovell
Copy link
Contributor

A few minor comments. Looks good otherwise.

@SparkQA
Copy link

SparkQA commented Apr 5, 2018

Test build #88930 has finished for PR 20981 at commit 35539be.

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

@viirya
Copy link
Member Author

viirya commented Apr 9, 2018

@hvanhovell Addressed your comment. Thanks.

@SparkQA
Copy link

SparkQA commented Apr 9, 2018

Test build #89042 has finished for PR 20981 at commit 2eb2bf1.

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

@SparkQA
Copy link

SparkQA commented Apr 9, 2018

Test build #89040 has finished for PR 20981 at commit a8cdbe8.

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

@viirya
Copy link
Member Author

viirya commented Apr 9, 2018

retest this please.


override def toString: String = s"input[$ordinal, ${dataType.simpleString}, $nullable]"

private lazy val accessor: InternalRow => Any = InternalRow.getAccessor(dataType, ordinal)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to be lazy?

case t: StructType => (input) => input.getStruct(ordinal, t.size)
case _: ArrayType => (input) => input.getArray(ordinal)
case _: MapType => (input) => input.getMap(ordinal)
case _ => (input) => input.get(ordinal, dataType)
Copy link
Contributor

Choose a reason for hiding this comment

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

Handle UDT?

@SparkQA
Copy link

SparkQA commented Apr 9, 2018

Test build #89048 has finished for PR 20981 at commit 2eb2bf1.

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

/**
* Returns an accessor for an InternalRow with given data type and ordinal.
*/
def getAccessor(dataType: DataType, ordinal: Int): (InternalRow) => Any = dataType match {
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we can make the accessor accept SpecializedGetters, so this can be reused in #20984 too...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, no. The accessor in #20984 takes ordinal as input parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well you could generalize to make it take an ordinal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

@SparkQA
Copy link

SparkQA commented Apr 10, 2018

Test build #89101 has finished for PR 20981 at commit 912c2c2.

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

}


private def getActualDataType(dt: DataType): DataType = dt match {
Copy link
Contributor

Choose a reason for hiding this comment

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

I added a similar method to the UserDefinedType companion. Which one shall we add?

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 can use the method you added.

* actually takes a `SpecializedGetters` input because it can be generalized to other classes
* that implements `SpecializedGetters` (e.g., `ArrayData`) too.
*/
def getAccessor(dataType: DataType): (SpecializedGetters, Int) => Any = dataType match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we should move this to the companion object of SpecializedGetters?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

As SpecializedGetters is a java interface, seems we can't create a companion object for it? Or I miss something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hehe - good point. Let's leave it here for now.

@hvanhovell
Copy link
Contributor

Looks good. Two more comments.

@SparkQA
Copy link

SparkQA commented Apr 10, 2018

Test build #89123 has finished for PR 20981 at commit 54dd939.

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

@hvanhovell
Copy link
Contributor

LGTM

@SparkQA
Copy link

SparkQA commented Apr 11, 2018

Test build #89186 has finished for PR 20981 at commit 5711ea1.

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

@viirya
Copy link
Member Author

viirya commented Apr 11, 2018

retest this please.

@SparkQA
Copy link

SparkQA commented Apr 11, 2018

Test build #89199 has finished for PR 20981 at commit 5711ea1.

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

@viirya
Copy link
Member Author

viirya commented Apr 12, 2018

retest this please.

@SparkQA
Copy link

SparkQA commented Apr 12, 2018

Test build #89262 has finished for PR 20981 at commit 5711ea1.

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

@viirya
Copy link
Member Author

viirya commented Apr 13, 2018

ping @hvanhovell

@hvanhovell
Copy link
Contributor

Merging to master. Sorry for the long wait.

@asfgit asfgit closed this in fd990a9 Apr 16, 2018
@viirya viirya deleted the SPARK-23873 branch December 27, 2023 18:35
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.

3 participants