Skip to content

[SPARK-22003][SQL] support array column in vectorized reader with UDF - #19230

Closed
liufengdb wants to merge 4 commits into
apache:masterfrom
liufengdb:fix_array_open
Closed

[SPARK-22003][SQL] support array column in vectorized reader with UDF#19230
liufengdb wants to merge 4 commits into
apache:masterfrom
liufengdb:fix_array_open

Conversation

@liufengdb

Copy link
Copy Markdown

What changes were proposed in this pull request?

The UDF needs to deserialize the UnsafeRow. When the column type is Array, the get method from the ColumnVector, which is used by the vectorized reader, is called, but this method is not implemented.

How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)

Please review http://spark.apache.org/contributing.html before opening a pull request.

@viirya

viirya commented Sep 14, 2017

Copy link
Copy Markdown
Member

Add a test for it?

} else if (dt instanceof StringType) {
for (int i = 0; i < length; i++) {
if (!data.isNullAt(offset + i)) {
list[i] = getUTF8String(i).toString();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks suspicious. Why we get String before? Seems we should get UTF8String.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks like a bug.

for (int i = 0; i < length; i++) {
if (!data.isNullAt(offset + i)) {
list[i] = data.getDouble(offset + i);
list[i] = getAtMethod.call(i);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we just call get(i + offset, dt)? The getAtMethod seems not very useful, as we still need to go through the if-else branches in get everytime.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It should be get(i, dt)? I updated it anyway.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yea should be get(i, dt).

@SparkQA

SparkQA commented Sep 14, 2017

Copy link
Copy Markdown

Test build #81759 has finished for PR 19230 at commit adbaeab.

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

@cloud-fan

Copy link
Copy Markdown
Contributor

since ColumnVector is only used by vectorized parquet reader, and it currently doesn't support nested types, so I can't think of an end-to-end regression test. However we can still have a unit test for ColumnVector.

@viirya

viirya commented Sep 15, 2017

Copy link
Copy Markdown
Member

Yea we should add an unit test for it.

@liufengdb

Copy link
Copy Markdown
Author

@viirya @cloud-fan unit test updated.

*/
package org.apache.spark.sql.execution.vectorized;

import org.apache.spark.api.java.function.Function;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't use this now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@liufengdb I think we don't need to import this now?

@SparkQA

SparkQA commented Sep 16, 2017

Copy link
Copy Markdown

Test build #81835 has finished for PR 19230 at commit 19502f9.

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

// Populate it with arrays [0], [1, 2], [], [3, 4, 5]
testVector.putArray(0, 0, 1)
testVector.putArray(1, 1, 2)
testVector.putArray(2, 2, 0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it doesn't affect the result. But looks like the third array should be testVector.putArray(2, 3, 0)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@viirya

viirya commented Sep 16, 2017

Copy link
Copy Markdown
Member

@liufengdb The PR description looks like an end-to-end failure. I'm curious are you facing the failure in an end-to-end case?

dst.getChildColumn(1).appendLong(c.microseconds);
} else if (t instanceof DateType) {
dst.appendInt(DateTimeUtils.fromJavaDate((Date)o));
dst.appendInt((int) DateTimeUtils.fromJavaDate((Date)o));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it necessary?

@cloud-fan

Copy link
Copy Markdown
Contributor

LGTM except some minor comments

@viirya

viirya commented Sep 16, 2017

Copy link
Copy Markdown
Member

LGTM too.

@SparkQA

SparkQA commented Sep 17, 2017

Copy link
Copy Markdown

Test build #81850 has finished for PR 19230 at commit 5cbf978.

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

*/
package org.apache.spark.sql.execution.vectorized;

import org.apache.spark.api.java.function.Function;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please revert it back.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oops, reverted it.

assert(array.get(1, schema).asInstanceOf[ColumnarBatch.Row].get(0, IntegerType) === 456)
assert(array.get(1, schema).asInstanceOf[ColumnarBatch.Row].get(1, DoubleType) === 5.67)
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it better to add a test for map, too?

@liufengdb liufengdb Sep 18, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see.
Does your change expect that this call finally throws an exception for Map element in array?

@gatorsmile

Copy link
Copy Markdown
Member

retest this please

@SparkQA

SparkQA commented Sep 18, 2017

Copy link
Copy Markdown

Test build #81861 has finished for PR 19230 at commit 5ea4e89.

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

@gatorsmile

Copy link
Copy Markdown
Member

retest this please

1 similar comment
@cloud-fan

Copy link
Copy Markdown
Contributor

retest this please

@kiszk

kiszk commented Sep 18, 2017

Copy link
Copy Markdown
Member

Can we add test code for null row in a column for each type?

@SparkQA

SparkQA commented Sep 18, 2017

Copy link
Copy Markdown

Test build #81872 has finished for PR 19230 at commit 5ea4e89.

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

@cloud-fan

Copy link
Copy Markdown
Contributor

retest this please

@SparkQA

SparkQA commented Sep 18, 2017

Copy link
Copy Markdown

Test build #81877 has finished for PR 19230 at commit 5ea4e89.

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

@gatorsmile

Copy link
Copy Markdown
Member

Thanks! Merged to master.

@asfgit asfgit closed this in 3b049ab Sep 18, 2017
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.

6 participants