Skip to content

Conversation

@ueshin
Copy link
Member

@ueshin ueshin commented Jul 20, 2018

What changes were proposed in this pull request?

If we use reverse function for array type of primitive type containing null and the child array is UnsafeArrayData, the function returns a wrong result because UnsafeArrayData doesn't define the behavior of re-assignment, especially we can't set a valid value after we set null.

How was this patch tested?

Added some tests.

@ueshin
Copy link
Member Author

ueshin commented Jul 20, 2018

cc @mn-mikke @cloud-fan @gatorsmile

@mn-mikke
Copy link
Contributor

Thanks @ueshin for this PR! Good to know about the re-assignments.

@SparkQA
Copy link

SparkQA commented Jul 20, 2018

Test build #93353 has finished for PR 21830 at commit 91978e7.

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

)
}

// Test with local relation, the Project will be evaluated without codegen
Copy link
Member

Choose a reason for hiding this comment

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

There are many tests here, so I think it'd be nice to split the tests into two or three parts.

| ${ev.value}.$setFunc(k, ${getCall("l")});
| ${ev.value}.setNullAt(l);
|}""".stripMargin
val arrayDataClass = classOf[GenericArrayData].getName()
Copy link
Member

Choose a reason for hiding this comment

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

nit: getName() -> getName


val initialization = if (isPrimitiveType) {
s"$childName.copy()"
ctx.createUnsafeArray(arrayData, numElements, elementType, s" $prettyName failed.")
Copy link
Member

@maropu maropu Jul 21, 2018

Choose a reason for hiding this comment

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

The code in the master doesn't create UnsafeArrayData per input row though, it seems this change does so. Can we avoid it?

Copy link
Member

Choose a reason for hiding this comment

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

IIUC, the code in the master also create UnsafeArrayData per input row in UnsafeArrayData.copy().

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I talked with @ueshin and no problem about this.

@SparkQA
Copy link

SparkQA commented Jul 23, 2018

Test build #93425 has finished for PR 21830 at commit 30d08ca.

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

|final int $numElements = $childName.numElements();
|$initialization
|for (int $i = 0; $i < $numElements; $i++) {
| int $j = $numElements - $i - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need j if we do

for (int i = numElements - 1; i >=0; i--)

Copy link
Member Author

Choose a reason for hiding this comment

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

We still need to calculate the index of the opposite side?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah i see

"update"
}

val assignment = if (isPrimitiveType && dataType.asInstanceOf[ArrayType].containsNull) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we can simplify the code if we do override def dataType: ArrayType = child.dataType.asInstanceOf[ArrayType]

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't override dataType only for ArrayType because Reverse is also used for StringType.

@cloud-fan
Copy link
Contributor

LGTM

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@asfgit asfgit closed this in c9b233d Jul 26, 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.

6 participants