mbutrovich commented on code in PR #3632:
URL: https://github.com/apache/iceberg-rust/pull/3632#discussion_r4667141524
##########
crates/iceberg/src/arrow/schema.rs:
##########
@@ -346,6 +346,9 @@ fn visit_type<V: ArrowSchemaVisitor>(r#type: &DataType,
visitor: &mut V) -> Resu
}
DataType::List(element_field) => visit_list(r#type, element_field,
visitor),
DataType::LargeList(element_field) => visit_list(r#type,
element_field, visitor),
+ DataType::ListView(element_field) |
DataType::LargeListView(element_field) => {
+ visit_list(r#type, element_field, visitor)
+ }
Review Comment:
This arm also sends `ListView` and `LargeListView` to the other two
`ArrowSchemaVisitor` impls, and their `list` methods don't match them:
[`ArrowSchemaConverter::list`](https://github.com/apache/iceberg-rust/blob/809637059f17244291dd8481eb9c1724a6b9e83c/crates/iceberg/src/arrow/schema.rs#L625-L633)
and
[`MetadataStripVisitor::list`](https://github.com/apache/iceberg-rust/blob/809637059f17244291dd8481eb9c1724a6b9e83c/crates/iceberg/src/arrow/schema.rs#L1530-L1541).
The public functions built on them still fail on a list view, but now with
misleading errors. For a schema with one `ListView<Int32>` column:
| Function | `main` | This PR |
|---|---|---|
| `arrow_schema_to_schema` | `DataInvalid`: `Cannot visit Arrow data type:
ListView(...)` | `DataInvalid`: `List type must have list data type` |
| `strip_metadata_from_schema` | `DataInvalid`: `Cannot visit Arrow data
type: ListView(...)` | `Unexpected`: `Expected list type, got ListView(...)` |
`LargeListView` behaves the same way. Could we add `ListView` and
`LargeListView` arms to both `list` methods, so `arrow_schema_to_schema` reads
a list view as an Iceberg `list` and `strip_metadata_from_schema` keeps the
list view type? A test for each would cover it.
##########
crates/iceberg/src/arrow/reader/projection.rs:
##########
@@ -84,6 +84,8 @@ impl ArrowReader {
(Some(lhs), Some(rhs)) if lhs == rhs => true,
(Some(PrimitiveType::Int), Some(PrimitiveType::Long)) => true,
(Some(PrimitiveType::Float), Some(PrimitiveType::Double)) =>
true,
+ (Some(PrimitiveType::TimestampNs),
Some(PrimitiveType::Timestamp))
+ | (Some(PrimitiveType::TimestamptzNs),
Some(PrimitiveType::Timestamptz)) => true,
Review Comment:
These two arms aren't [type
promotions](https://github.com/apache/iceberg/blob/69a3d2b560ac8ad20eaf995625639a43a1be3254/format/spec.md?plain=1#L408-L416)
in the spec's sense, and the spec has writers store `timestamp` and
`timestamptz` as
[`TIMESTAMP_MICROS`](https://github.com/apache/iceberg/blob/69a3d2b560ac8ad20eaf995625639a43a1be3254/format/spec.md?plain=1#L1927-L1928).
Someone reading `type_promotion_is_valid` later will wonder why it accepts
nanoseconds here. Could we add a comment like the one on the `Uuid` arm below?
```suggestion
// Not a spec type promotion. Migrated files (for example
from `add_files`) can
// store `TIMESTAMP(NANOS)` under a microsecond field, and
`RecordBatchTransformer`
// casts them to microseconds.
(Some(PrimitiveType::TimestampNs),
Some(PrimitiveType::Timestamp))
| (Some(PrimitiveType::TimestamptzNs),
Some(PrimitiveType::Timestamptz)) => true,
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]