scovich commented on code in PR #9599:
URL: https://github.com/apache/arrow-rs/pull/9599#discussion_r2989963831
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
Review Comment:
```suggestion
} else if treat_invalid_as_null(&self.cast_options, value) {
```
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
@@ -545,6 +559,9 @@ impl<'a> StructVariantToArrowRowBuilder<'a> {
}
fn append_value(&mut self, value: &Variant<'_, '_>) -> Result<bool> {
+ if append_null_if_variant_null(value, || self.append_null())? {
+ return Ok(false);
+ }
let Variant::Object(obj) = value else {
if self.cast_options.safe {
Review Comment:
Instead of `append_null_if_variant_null` can do:
```suggestion
if value.is_null() || self.cast_options.safe {
```
(would need to define `Variant::is_null() -> bool` and probably update
`Variant::as_null()` to use it)
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
Review Comment:
```suggestion
if !treat_invalid_as_null(&self.cast_options, value) {
```
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
Review Comment:
```suggestion
None if treat_invalid_as_null(&self.cast_options, value) => {
```
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
Review Comment:
```suggestion
_ if treat_invalid_as_null(&self.cast_options, value) => {
```
##########
parquet-variant-compute/src/variant_to_arrow.rs:
##########
@@ -545,6 +559,9 @@ impl<'a> StructVariantToArrowRowBuilder<'a> {
}
fn append_value(&mut self, value: &Variant<'_, '_>) -> Result<bool> {
+ if append_null_if_variant_null(value, || self.append_null())? {
+ return Ok(false);
+ }
let Variant::Object(obj) = value else {
if self.cast_options.safe {
Review Comment:
Could get fancier and add a different helper function:
```rust
fn treat_invalid_as_null(cast_options: &CastOptions<'_>, value: &Variant<'_,
'_>) -> bool {
value.is_null() || cast_options.safe
}
```
and then use that everywhere
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]