manuzhang commented on code in PR #662:
URL: https://github.com/apache/iceberg-cpp/pull/662#discussion_r3287060955
##########
src/iceberg/schema_util.cc:
##########
@@ -79,6 +82,55 @@ Status ValidateSchemaEvolution(const Type& expected_type,
const Type& source_typ
return NotSupported("Cannot read {} from {}", expected_type, source_type);
}
+Result<FieldProjection> ProjectNested(const Type& expected_type, const Type&
source_type,
+ bool prune_source);
+
+Result<FieldProjection> ProjectField(const SchemaField& expected_field,
+ const SchemaField& source_field, size_t
source_index,
+ bool prune_source) {
+ FieldProjection projection;
+
+ if (expected_field.type()->type_id() == TypeId::kUnknown) {
+ if (!expected_field.optional()) {
+ return InvalidSchema("Cannot project required field with id {} as null",
+ expected_field.field_id());
+ }
+ projection.kind = FieldProjection::Kind::kNull;
+ return projection;
+ }
+
+ if (source_field.type()->type_id() == TypeId::kUnknown &&
+ expected_field.type()->is_nested()) {
+ if (!expected_field.optional()) {
+ return InvalidSchema("Cannot project required field with id {} as null",
+ expected_field.field_id());
+ }
+ projection.kind = FieldProjection::Kind::kNull;
+ return projection;
+ }
+
+ if (source_field.type()->type_id() == TypeId::kUnknown &&
!expected_field.optional()) {
+ return InvalidSchema("Cannot project required field with id {} as null",
+ expected_field.field_id());
+ }
+
+ if (expected_field.type()->is_nested()) {
Review Comment:
Can you point me to the spec or impl where it's not allowed?
--
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]