wgtmac commented on code in PR #1068:
URL: https://github.com/apache/iceberg-cpp/pull/1068#discussion_r4697027188


##########
src/iceberg/table_scan.h:
##########
@@ -88,7 +90,8 @@ class ICEBERG_EXPORT FileScanTask : public ScanTask {
   static Result<std::shared_ptr<FileScanTask>> MakeSplit(
       std::shared_ptr<DataFile> data_file, int64_t start, int64_t length,
       std::vector<std::shared_ptr<DataFile>> delete_files = {},
-      std::shared_ptr<Expression> filter = nullptr);
+      std::shared_ptr<Expression> filter = nullptr,
+      std::shared_ptr<PartitionSpec> spec = nullptr);

Review Comment:
   `FileScanTaskSplitCursor::Next` omits this argument, so planned Parquet 
splits lose the spec and `Open` rejects them. Pass the parent spec and test a 
partitioned file through `PlanTasks`.



##########
src/iceberg/parquet/parquet_reader.cc:
##########
@@ -153,8 +155,9 @@ class ParquetReader::Impl {
                                                     arrow_reader_properties));
 
     // Project read schema onto the Parquet file schema
-    ICEBERG_ASSIGN_OR_RAISE(projection_, BuildProjection(reader_.get(), 
*read_schema_,
-                                                         
options.name_mapping.get()));
+    ICEBERG_ASSIGN_OR_RAISE(
+        projection_, BuildProjection(reader_.get(), *read_schema_,
+                                     options.name_mapping.get(), 
options.id_to_constant));

Review Comment:
   Footer stats still describe the physical values. If the physical column says 
`file` and the constant is `CN`, a `name = 'CN'` filter can prune every row. 
Ignore stats for overridden IDs and add a regression with filtering enabled.



##########
src/iceberg/parquet/parquet_data_util.cc:
##########
@@ -252,7 +252,8 @@ Result<std::shared_ptr<::arrow::Array>> ProjectStructArray(
             projected_array,
             ProjectPrimitiveArray(parquet_array, output_arrow_type, pool));
       }
-    } else if (field_projection.kind == FieldProjection::Kind::kDefault) {
+    } else if (field_projection.kind == FieldProjection::Kind::kDefault ||
+               field_projection.kind == FieldProjection::Kind::kConstant) {

Review Comment:
   A v3 identity partition can supply `Literal::Null(unknown())`. Both readers 
resolve its source type before checking for null and fail. Materialize nulls 
using the output type.



##########
src/iceberg/avro/avro_data_util.cc:
##########
@@ -594,7 +596,8 @@ Status 
PrepareStructDefaultScalars(std::span<FieldProjection> projections,
     auto& field_projection = projections[i];
     auto* field_builder = struct_builder->field_builder(static_cast<int>(i));
 
-    if (field_projection.kind == FieldProjection::Kind::kDefault) {
+    if (field_projection.kind == FieldProjection::Kind::kDefault ||
+        field_projection.kind == FieldProjection::Kind::kConstant) {

Review Comment:
   An old task can supply `decimal(9,2)` to a `decimal(18,2)` projection. 
Arrow's `Scalar::CastTo` rejects that widening. Use a decimal-capable cast and 
cover both Avro decoders.



-- 
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]

Reply via email to