Skip to content

Conversation

@sarutak
Copy link
Member

@sarutak sarutak commented Jul 7, 2020

What changes were proposed in this pull request?

This PR fixes an inconsistency in EvaluatePython.makeFromJava, which creates a type conversion function for some Java/Scala types.

other is a type but it should actually pass obj:

case other => (obj: Any) => nullSafeConvert(other)(PartialFunction.empty) 

This does not change the output because it always returns null for unsupported datatypes.

Why are the changes needed?

To make the codes coherent, and consistent.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

No behaviour change.

case udt: UserDefinedType[_] => makeFromJava(udt.sqlType)

case other => (obj: Any) => nullSafeConvert(other)(PartialFunction.empty)
case other => (obj: Any) => nullSafeConvert(obj)(PartialFunction.empty)
Copy link
Member

Choose a reason for hiding this comment

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

Hi, @sarutak . Can we have a test case for this?

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Member

Choose a reason for hiding this comment

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

btw, for any input, this converter in this pattern returns null? I mean we cannot write it here like this?

case other => (_: Any) => null

Copy link
Member Author

@sarutak sarutak Jul 8, 2020

Choose a reason for hiding this comment

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

btw, for any input, this converter in this pattern returns null?

Yes so it's difficult to test based on the return value.
Or, how about testing that the converter still returns null, meaning there is no regression?

Copy link
Member

Choose a reason for hiding this comment

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

either way seems fine to me

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

I don't think there's any user-facing behaviour change after this fix .. let's clarify this is just a cleanup in the PR description.

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LGTM

@SparkQA
Copy link

SparkQA commented Jul 8, 2020

Test build #125261 has finished for PR 29029 at commit ec0d619.

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

@HyukjinKwon
Copy link
Member

I changed the PR description by myself.

Merged to master, branch-3.0 and branch-2.4.

HyukjinKwon pushed a commit that referenced this pull request Jul 8, 2020
…Java for "other" type uses a wrong variable

### What changes were proposed in this pull request?

This PR fixes an inconsistency in `EvaluatePython.makeFromJava`, which creates a type conversion function for some Java/Scala types.

`other` is a type but it should actually pass `obj`:

```scala
case other => (obj: Any) => nullSafeConvert(other)(PartialFunction.empty)
```

This does not change the output because it always returns `null` for unsupported datatypes.

### Why are the changes needed?

To make the codes coherent, and consistent.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

No behaviour change.

Closes #29029 from sarutak/fix-makeFromJava.

Authored-by: Kousuke Saruta <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
(cherry picked from commit 371b35d)
Signed-off-by: HyukjinKwon <[email protected]>
HyukjinKwon pushed a commit that referenced this pull request Jul 8, 2020
…Java for "other" type uses a wrong variable

### What changes were proposed in this pull request?

This PR fixes an inconsistency in `EvaluatePython.makeFromJava`, which creates a type conversion function for some Java/Scala types.

`other` is a type but it should actually pass `obj`:

```scala
case other => (obj: Any) => nullSafeConvert(other)(PartialFunction.empty)
```

This does not change the output because it always returns `null` for unsupported datatypes.

### Why are the changes needed?

To make the codes coherent, and consistent.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

No behaviour change.

Closes #29029 from sarutak/fix-makeFromJava.

Authored-by: Kousuke Saruta <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
(cherry picked from commit 371b35d)
Signed-off-by: HyukjinKwon <[email protected]>
@sarutak
Copy link
Member Author

sarutak commented Jul 8, 2020

@HyukjinKwon Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants