-
Notifications
You must be signed in to change notification settings - Fork 48
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
Reading Arrow NullVector #550
Conversation
@@ -249,7 +249,7 @@ internal class ArrowWriterImpl( | |||
strictType: Boolean, | |||
strictNullable: Boolean, | |||
): FieldVector { | |||
val containNulls = (column == null || column.hasNulls()) | |||
val containNulls = (column == null || column.values().any { it == null}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this line as it's less efficient. The hasNulls()
/isMarkedNullable
is set upon column creation and since columns are immutable we can safely assume all values are not null if hasNulls() == false
. Maybe we could only run this check if strictNullable == true
, wdyt @koperagen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I have removed that commit on rebasing to new master. But we still can specify nullable type for not-null values and vice versa (look first message in #428, that test is reproduceable just now).
Maybe we could only run this check if
strictNullable == true
Sounds good, I can make this in separate PR. Or we should fix #428 totally in any another way (such as keeping "nullable" for types and "hasNulls" for values independently). You were agree that hasNulls()
should only return true if there are actually nulls in the column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're indeed still working on figuring out a good way to fix #428 so that the cases you gave are not possible anymore. That way hasNulls() == isMarkedNullable
at all times. The difficult part is finding a good balance between performance and safety. We don't want to have to scan an entire list of data if a user can ensure it has or has no nulls...
dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/arrowReadingImpl.kt
Outdated
Show resolved
Hide resolved
Should we apply |
Rebased |
Thanks for the help! I'll run the CI and merge :) |
@Kopilov Looks like the test
This probably means we need my entire solution with ...
@JvmName("withTypeNullableNothingList")
private fun List<Nothing?>.withTypeNullable(
expectedNulls: Boolean,
nullabilityOptions: NullabilityOptions,
): Pair<List<Nothing?>, KType> {
val nullable = nullabilityOptions.applyNullability(this, expectedNulls)
return this to nothingType(nullable)
} and then is NullVector -> vector.values(range).withTypeNullable(field.isNullable, nullability) |
@Jolanrensen applied, thanks |
Apache Arrow files might contain
NullVector
values (as result of saving null-infilled column in other libraries and languages without static types and target schema). From this PR they will be correctly read by Kotlin DataFrame instead of crushing. Also we can make saving toNullVector
s, should we?Among others, Arrow itself is upgraded to last stable version (14.0.2) and #428 problem is fixed for Arrow writing by replacing original
hasNulls
function with custom explicit checking.