iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

Core: Fix filed ids of partition stats file

Open ajantha-bhat opened this issue 1 year ago • 7 comments

While working on DV support for partition stats, observed that schema field ids of partition stats file is not as per spec. Spec, field id starts from 1 and java implementation the filed id starts from 0.

This happened because of this refactoring PR. We missed that field ids are tracked in spec. We wanted to avoid ugly code of index-1 when reused the filed id for StructLike.

Updated schema id as per spec (starts from 1). Uses separate position variables for StructLike (starts from 0). Handled compatibility of reading old corrupted stats to fallback on full compute.

ajantha-bhat avatar Jun 17 '25 07:06 ajantha-bhat

@lirui-apache, @deniskuzZ: Just a heads up as you guys are using this feature as per my knowledge. And sorry for this oversight during refactoring!

ajantha-bhat avatar Jun 17 '25 10:06 ajantha-bhat

@lirui-apache, @deniskuzZ: Just a heads up as you guys are using this feature as per my knowledge.

Thanks @ajantha-bhat , we are also looking at the issue internally. Guess I can incorporate your fix when it's done.

lirui-apache avatar Jun 17 '25 10:06 lirui-apache

Thanks @ajantha-bhat for the heads up, we've just upgraded the Hive to Iceberg 1.9.1

deniskuzZ avatar Jun 17 '25 13:06 deniskuzZ

off-topic: partition stats file format is highly coupled with table write.format. If CU is using ORC, he automatically loses the partition stats. Do you think we can decouple the file formats? If yes, I can raise a PR for that.

deniskuzZ avatar Jun 17 '25 13:06 deniskuzZ

off-topic: partition stats file format is highly coupled with table write.format. If CU is using ORC, he automatically loses the partition stats.

Yes. In the initial proposal document jack-ye has brought this up. Spec was hardcoded that it should be in table default format. Then we updated that it can be any of the format (https://iceberg.apache.org/spec/#partition-statistics-file).

So, we can have a table property to configure a different format stats than data format. But I recommend supporting InternalData for ORC, I can help on it too if needed (I did it for parquet and avro). So, that ORC can be used for writing table metadata in v4. Than changing the format of partition stats here.

ajantha-bhat avatar Jun 17 '25 16:06 ajantha-bhat

Flink new flaky test: https://github.com/apache/iceberg/issues/13338

ajantha-bhat avatar Jun 18 '25 01:06 ajantha-bhat

off-topic: partition stats file format is highly coupled with table write.format. If CU is using ORC, he automatically loses the partition stats.

Yes. In the initial proposal document jack-ye has brought this up. Spec was hardcoded that it should be in table default format. Then we updated that it can be any of the format (https://iceberg.apache.org/spec/#partition-statistics-file).

So, we can have a table property to configure a different format stats than data format. But I recommend supporting InternalData for ORC, I can help on it too if needed (I did it for parquet and avro). So, that ORC can be used for writing table metadata in v4. Than changing the format of partition stats here.

@ajantha-bhat, that would be awesome if we add an InternalData reader/writer for ORC. However, I am not sure how big that effort would be. If i understand correctly, we'll need to implement support for a few missing features, such as default values, timestamp(9), variant

deniskuzZ avatar Jun 18 '25 09:06 deniskuzZ

Merged to main. Thanks for the fix @ajantha-bhat and @lirui-apache and @deniskuzZ for the review.

This is an important change which we have to highlight in the release notes. @ajantha-bhat: Please create those. CC: @stevenzwu - Please don't forget to add this to the 1.10.0 release notes. In nutshell: The schema of partition stats files generated by the 1.9.x Iceberg releases were incorrect (wrong fieldIds), and this is fixed starting from 1.10.0. The old stats files need to be recalculated, otherwise they will be unusable.

pvary avatar Jun 25 '25 06:06 pvary