Skip to content

Conversation

@simhadri-g
Copy link
Member

@simhadri-g simhadri-g commented Aug 1, 2023

…b types to puffin file

Issue:
#8198

Hi Everyone,

Hive now supports writing column statistics to puffin files.

The statistics calculated by Hive include histograms, NDV (Number of Distinct Values), Min and Max values, the number of nulls, the number of true values, column name, and column type. You can find the full list of supported stats here: Link to GitHub.

We are updating the description of this PR to request incorporating the KLL datasketch for histograms.

As a result, we are looking to add KLL datasketch as standard blob types for the puffin file. Link to GitHub

Any feedback would be greatly appreciated.

Thanks!

@github-actions github-actions bot added the core label Aug 1, 2023
@nastra nastra requested a review from findepi August 1, 2023 11:31
@simhadri-g
Copy link
Member Author

Thanks a lot for the review! :)

@simhadri-g
Copy link
Member Author

@findepi I have addressed the review comments.

Can you please have a look at the PR when you are free?
Thanks in advance! :)

@simhadri-g simhadri-g requested a review from findepi August 3, 2023 13:51
@simhadri-g
Copy link
Member Author

Hello @findepi @nastra ,
I would greatly appreciate it if you could find some time to review the pull request.
Thanks!

@simhadri-g
Copy link
Member Author

Thanks for the review :)
I will update the PR and get back.

@simhadri-g
Copy link
Member Author

@nastra , I have updated the PR and moved the iceberg-docs(apache/iceberg-docs#269) changes to the main repo.

Please have a look when you are free.

Thanks again for the review!

Copy link
Contributor

@nastra nastra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, @findepi could you review this as well please?

@simhadri-g
Copy link
Member Author

thanks @nastra for the review! :)

@findepi Could you please have a look as well?
Thanks!

@ZacBlanco
Copy link

Any progress update here? It would be great to get the blessing from the Iceberg community for these as supported puffin blob types

@bitsondatadev
Copy link
Collaborator

@findepi @danielcweeks could one of you PTAL this? Don't want this effort to get lost.

@bitsondatadev
Copy link
Collaborator

@simhadri-g update I'm following up on this today.

@simhadri-g
Copy link
Member Author

thanks @bitsondatadev !

@zhangbutao
Copy link
Contributor

Any update? hope we can continue to push this review forward.
Thanks.


#### `hive-column-statistics-obj` blob type

A serialized form of Hive ColumnStatsObject.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is what's referenced here the Thrift ColumnStatisticsObj in the Hive IDL? https://github.com/apache/hive/blob/ffb1165f59defa66b31b4fd9cb6367b71050071b/standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift#L583

If so, I'd recommend correcting the name, and linking to the Thrift IDL, and explicitly calling out that this is Thrift-serialized.

I'm also wondering if we need to think about versioning. If this is based on the Thrift IDL, I am not sure if those are intended to be persisted. At the very least, I am concerned if Hive decides to introduce a backwards-incompatible field to this struct, some engines begin to serialize with this newly introduced backwards incompatible field, and other engines begin to attempt to deserialize it with an older IDL, then it will break in the Iceberg library.

Please let me know if I'm misunderstanding anything.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
In hive , we writes the statistics to HMS in addition to puffin files.
So the Thrift ColumnStatisticsObj is used to write the statistics to HMS.

hive-column-statistics-obj referred here is a serialized using the org.apache.commons.lang3.SerializationUtils and stored into puffin file.

@simhadri-g
Copy link
Member Author

Hi everyone,
I would be most grateful if we could get help with reviewing this.
Thanks!

@github-actions
Copy link

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Sep 10, 2024
@github-actions
Copy link

This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions bot closed this Sep 18, 2024
@deniskuzZ
Copy link
Member

hi @simhadri-g, would you mind reopening this PR?

@simhadri-g
Copy link
Member Author

simhadri-g commented Feb 4, 2025

Hi Denys!
I think , I don't have the github permissions to reopen a closed PR in iceberg repo.
Should i raise a new PR?

@deniskuzZ
Copy link
Member

deniskuzZ commented Feb 4, 2025

Hi Denys! I think , I don't have the github permissions to reopen a closed PR in iceberg repo. Should i raise a new PR?

hey @simhadri-g, if you'd like to pursue this I would recommend opening a new one, but split into 2 parts: Hive ColumnStatistics and KLL Datasketch

@nastra nastra reopened this Feb 4, 2025
@github-actions github-actions bot added the Specification Issues that may introduce spec changes. label Feb 4, 2025
@nastra nastra added not-stale and removed Specification Issues that may introduce spec changes. stale labels Feb 4, 2025
@deniskuzZ
Copy link
Member

deniskuzZ commented Feb 4, 2025

thanks @nastra! It would really help if we could get this in.

@simhadri-g
Copy link
Member Author

thanks @nastra and @deniskuzZ !

I will resolve the merge conflicts and update this PR. :)

@github-actions github-actions bot added the Specification Issues that may introduce spec changes. label Feb 4, 2025
@nastra
Copy link
Contributor

nastra commented Feb 4, 2025

@findepi Could you please have a look as well?

[roaring-bitmap-portable-serialization]: https://github.com/RoaringBitmap/RoaringFormatSpec?tab=readme-ov-file#extension-for-64-bit-implementations
[roaring-bitmap-general-layout]: https://github.com/RoaringBitmap/RoaringFormatSpec?tab=readme-ov-file#general-layout

#### `hive-column-statistics-obj` blob type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just FYI that adding changes to the Spec now requires a VOTE on the Dev mailing list in order to increase visibility for spec changes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I start [DISCUSS] thread first or go ahead with [VOTE]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also start with a DISCUSS thread first in order to have a short discussion on the introduced changes


The ColumnStatsObject supports Histograms, NDV, Min and Max values, Number of nulls, Number of trues, column name, type.
A full list of supported statistics is listed in the table here:
[ColumnStatistics](https://cwiki.apache.org/confluence/display/Hive/StatsDev#StatsDev-ColumnStatistics)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much value in adding this.

NDV sketches are already supported using Theta sketches so this would duplicate the purpose of an existing sketch. Is there sufficient value to justify the difference? This doesn't provide enough context to tell.

In addition, the Iceberg manifest format already covers value count, lower bounds, upper bounds, number of nulls, and number of NaNs. The partition statistics files provide a way to aggregate those beyond the file level, and we use snapshot summaries for table-level stats. I'm not sure what value this would provide.

Copy link
Member

@deniskuzZ deniskuzZ Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @rdblue,
thanks for checking this PR!

The partition statistics files provide a way to aggregate those beyond the file level
Does iceberg provide build-in support to get an aggregated Column stats? I mean, is there some library/service that generates partition files with an aggregated column stats?
AFAIK we only do this for basic stats : #11216

If yes, could you please point me to the code where is that done? I had an impression that from colstats only NDV is calculated and stored in partition files.

How about:

  1. bitvectors - used to improve stats estimations for IN operator
  2. histogram - histogram statistics, which are particularly useful for skewed data and range predicates (KLL data sketches)
  3. numTrue/numFalse
  4. avgColLen

Wouldn't it make sense to store in a single puffin file an aggregated partition column stats object per table snapshot with all the values?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @rdblue,
I'm sorry, it seems we had pretty limited knowledge in that area and now I think we finally get your point.
I've drafted a small doc with the proposal and our intent: https://docs.google.com/document/d/11Rp-irqb4L4Qpdxr6l83bA4IRsfw3AAyR8wokNe1r80/edit?usp=sharing
Could you please take a quick look and suggest if that is a valid proposal.
Thank you!

Apache-Datasketches-KLL-sketch is an implementation of a very compact quantiles
sketch with lazy compaction scheme and nearly optimal accuracy per bit.

Histograms are derived from this sketch.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't much to go on. How is the sketch calculated? Does this support a single column or multiple columns?

Copy link
Member

@deniskuzZ deniskuzZ Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per column: KllSketchUDF(columnName, columnStatsType)
more details: https://issues.apache.org/jira/browse/HIVE-26221

@danielcweeks
Copy link
Contributor

I would agree with @rdblue's comment that there's a lot of stats overlap with what exists elsewhere and I'm not convinced this serialized format is standardized well enough to be used easily outside of the Hive/Impala projects.

Could we identify the specific stats that we feel are valuable and focus on those independently of what is captured elsewhere?

@deniskuzZ
Copy link
Member

deniskuzZ commented Feb 5, 2025

I would agree with @rdblue's comment that there's a lot of stats overlap with what exists elsewhere and I'm not convinced this serialized format is standardized well enough to be used easily outside of the Hive/Impala projects.

Could we identify the specific stats that we feel are valuable and focus on those independently of what is captured elsewhere?

Hi @danielcweeks,
Thanks for your reply. I think we might have communicated our proposal not very clearly and had limited knowledge of that area.
I've drafted a doc with the proposal: https://docs.google.com/document/d/11Rp-irqb4L4Qpdxr6l83bA4IRsfw3AAyR8wokNe1r80/edit?usp=sharing
Hopefully, it would help to understand our intent. Could you please take a look?
Thank you!

@simhadri-g simhadri-g changed the title Core: Add KLL Datasketch and Hive ColumnStatisticsObj as standard blo… Core: Add KLL Datasketch as standard blob types to puffin file Feb 20, 2025
@deniskuzZ
Copy link
Member

deniskuzZ commented Mar 11, 2025

hi @nastra, could you please help push this change forward? I've updated the PR to include the KLL sketch only.

@nastra
Copy link
Contributor

nastra commented Mar 11, 2025

@deniskuzZ this is a spec change and needs to go through a DISCUSS & VOTE thread on the mailing list

@deniskuzZ
Copy link
Member

@deniskuzZ this is a spec change and needs to go through a DISCUSS & VOTE thread on the mailing list

This was a thread: https://lists.apache.org/thread/ws63loz1snsrwtdl7f9yqgr16vncx6w0
I don't know what else I should do other than just abandon the PR.
It looks like this change generated some interest until the recent comments, which I hope have been addressed, but I’m not sure since I haven't received any feedback.

@nastra
Copy link
Contributor

nastra commented Mar 11, 2025

@deniskuzZ you might just want to follow-up on the dev list to revive the discussion. Once it's clear in which direction the proposal is going and what Spec changes are required, you'd go ahead and create a VOTE thread for the Spec changes (this PR) where people can vote on the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core not-stale Specification Issues that may introduce spec changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants