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

SPARKC-504: Allow null UDTs against b3.0 branch #1241

Open
wants to merge 1 commit into
base: b3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ object MappedToGettableDataConverter extends StrictLogging {
for (i <- columnValues.indices)
columnValues(i) = converters(i).convert(columnValues(i))
struct.newInstance(columnValues: _*)
case None =>
case _ =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah my comment on _ was just that I thought we would explicitly match None and null just incase some other object got to this point in the match. I know that's impossible I just worry sometimes.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you see the case on line 204, "case obj if obj == null" Why doesn't this case match?

Copy link
Contributor

@RussellSpitzer RussellSpitzer Mar 31, 2020

Choose a reason for hiding this comment

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

I tried

 it should "convert null UDTs to null" in {
    val userTable = newTable(loginColumn, passwordColumn)
    val converter = MappedToGettableDataConverter[UserWithOption](userTable, userTable.columnRefs)
    val row = converter.convert(null)
    row shouldEqual null
  }

And this test passes without this code change, I think I may be missing something here

null.asInstanceOf[struct.ValueRepr]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ class MappedToGettableDataConverterSpec extends FlatSpec with Matchers {
row.isNullAt(1) shouldEqual true
}

it should "convert null UDTs to null" in {
val userTable = newTable(loginColumn, passwordColumn)
val converter = MappedToGettableDataConverter[UserWithOption](userTable, userTable.columnRefs)
val row = converter.convert(null)
row shouldEqual null
}

case class UserWithNestedOption(login: String, address: Option[Address])

it should "convert None case class to null" in {
Expand Down