GH-430: [Format] Add FINITE_VECTOR logical type with LIST storage #624
I don't think we should include nan_count since we forbid it above. I'm not clear on the representation for upper_lower bounds unless this is saying that it's the min/max element value, which doesn't make a whole lot of sense to me. Similar to list, I think we would just omit the upper/lower bounds and distinct count.
This paragraph is just restating what was already above, so I'd remove it.
I think Dan mentioned this below, but we can could probably just say "readers may assume nan_count = 0" and not store it.
How about this:
The sort order of `VECTOR` values is undefined and no statistics are defined
for whole vectors. Min/max values, `distinct_count`, column-index bounds,
and Bloom filters retain their ordinary LIST meaning. Bounds and distinct
counts describe scalar elements. Writers may omit them.
Agreed.
@RussellSpitzer how about this?
* (i.e. MUST assume nan_count > 0 and MAY NOT assume nan_count == 0).
* If the column is the element leaf of a VECTOR, whose elements MUST by
* convention always be finite (see LogicalTypes.md) writers SHOULD omit
* nan_count field and readers MAY assume nan_count == 0.
@RussellSpitzer continued from above
* NaN values in any page, except if the column is an element leaf of a
* VECTOR, whose elements MUST by convention always be finite (see
* LogicalTypes.md), writers SHOULD omit nan_counts field and
* readers MAY assume nan_counts == 0.
I'm not clear on the representation for upper_lower bounds unless this is saying that it's the min/max element value, which doesn't make a whole lot of sense to me.
It's meant as element-level (sub-row) statistics and can be omitted by writer.
Option B mentioned in the email from May eliminated? I see that only Option A and Option C1 are left in the email from September.
Thanks for the question @HuaHuaY ! Option B requires changes to physical layout of data - either via new repetition level or another mechanism. As logical and physical changes are somewhat independent and should likely both be done, we decided to propose them separately. So in short Option B is not eliminated, only delayed until logical type for vectors is settled. Apologies this was not clear from my communication.
I think now the sentence is cut off -- "nan_count MUST be" (must be what ? 0?)
I also don't see why we need to add a note for vector here -- the vector logical type spec says there can be no nans so then it follows nan_count must be zero. It seems unecessary to explicitly specify it
I also don't understand why we would need to call special handling for vector out -- isn't it the same interpretation as for any other type (as in for what type is min/max values not interpreted as metadata over the elements)?
The proposal seems pretty good to me -- I think there are some places where we could reduce its size and make it more concise, but the high level idea looks good
* convention always be finite (see LogicalTypes.md) nan_count MUST be
* zero when present.
Thanks for catching this! I think it's resolved now.
@alamb is this the right amount of detail?
The sort order of `VECTOR` values is undefined and no statistics are defined
for whole vectors.
this still seems overly specific to me. If the logical type forbids nans, why do we also need to specify anything about the statistics?
I would expect writers that write Vector logical type simply don't write nan statistics
yeah that makes sense to me. Thank you
Do we need to say this explicitly? I feel like this just reiterates that the physical storage is a list 🤔
+1, the current wording feels too specific / repetitive. First sentence says if nan_count is set, it must be 0. Second one says writers should omit nan_count and readers may assume it's 0. Can we just remove all of this? Agreed that writers likely won't emit nan_count for vectors and when they do, it's 0 by design. Anything non-zero is wrong.
Much of this is repeating what's in the other file. Can we just say something like:
Fixed-length vector logical type annotation
Annotates the outer group of a three-level LIST structure. Each
non-null list MUST contain exactly num_elements elements.
See LogicalTypes.md for details.
[nit] I'd remove Group elements...are not allowed. The supported list of types below is an allowlist, anything not in it is disallowed by definition
[nit] Suggest removing Whole vectors... as it's unrelated to the finite value constraint. Vectors being null is already covered above:
The outer level must be a group with `logicalType` set to `VECTOR` and
`converted_type` set to `LIST`. Its repetition must either be `optional` or
`required` and determines whether the vector may be null. It must contain a
single field named `list`.
+1
Small wording comments, but overall LGTM. Thanks for driving this @rok!
Agreed, this can be shortened, similar to how it is done for the FileType.
This sentence structure is a bit confusing, due to the added , writers SHOULD omit.... How about splitting the sentence:
* NaN values in any page, except if the column is an element leaf of a
* VECTOR, whose elements MUST by convention always be finite (see
* LogicalTypes.md). In this case, writers SHOULD omit nan_counts field and
* readers MAY assume nan_counts == 0.
nit: should must be capitalized in this and the next paragraph?
We could add an invalid example with 2 or 4 elements here.
I think due to some repeated editing, this paragraph is now present twice with slight variations.
Overall looks good to me!
Removing.
This reads cleanly to me now and I think clearly and precisely describes the new type. Thank you @rok
Thanks for the reviews @alamb and @wgtmac!
I tried to address all open comments. Also changed VECTOR -> FINITE_VECTOR as discussed on the ML. I feel the name better describes the application we're aiming for.
Thanks for driving this!
I’ve also been following the Iceberg vector proposal, and I’d like to raise two points about vector's metadata for discussion.
I agree that min/max statistics don’t make sense for vectors. However, there is other metadata that would make vector data more self-describing. It could live in Parquet or in Iceberg:
1. Distance function. See the reasoning from Harsha and the related discussion on the Iceberg side: https://docs.google.com/document/d/1zA8PskNDFKXXJpzWQr25CFoX_aIZHBNHbkxk0t3PteE/edit?disco=AAACDqu3oWI&pli=1
2. Lineage: which embedding model or API produced the vectors.
Just raising for discussion.
Hey @JigaoLuo thanks for reviewing! Discussion on points you raise would better fit the discusson on the ML (1, 2). I'll still try to reply here, but if you want to push this further the dev@parquet ML is the platform you should use.
there is other metadata that would make vector data more self-describing. It could live in Parquet or in Iceberg:
> 1. Distance function. See the reasoning from Harsha and the related discussion on the Iceberg side: https://docs.google.com/document/d/1zA8PskNDFKXXJpzWQr25CFoX_aIZHBNHbkxk0t3PteE/edit?disco=AAACDqu3oWI&pli=1
I am not an embeddings or vector DB expert, but wouldn't distance metric always an operation acting on pairs of vectors? It feels more like an application level concern and parquet already has a file-level metadata key-value metadata where such information could be stored. Or am I missing something here that could not be captured there?
2. Lineage: which embedding model or API produced the vectors.
Agreed that this is important information, but I'm not sure it's something that should live in the type. It would make parquet more self-contained, but it would require agreement on model identity between embedding producers which is out of reach for parquet. If you feel strongly about this, please sketch out how you imagine this would look like.
Hi @rok Thanks for sharing these. I'll go through the two discussions.
It feels more like an application level concern and parquet already has a file-level metadata key-value metadata where such information could be stored.
On point 1, I think this is a good place for it.
divjotarora
rok
Rationale for this change
Discussion on the ML led to a decision to split the logical annotation proposal from the original proposal, which also aimed to provide a physical representation. This PR proposes the logical annotation only, to address the need for a logical vector type.
Naming: the annotation is called
FINITE_VECTOR(previouslyVECTORin this PR) so that the name carries the contract: fixed length, non-null and finite elements. This leavesVECTORavailable should a future proposal introduce a more general vector type or a dedicated physical representation.---
This adds a
FINITE_VECTORlogical type stored as a canonical 3-level LIST structure. This is a contract on top of LIST, not a new physical representation:1. Each non-null vector contains exactly
num_elementselements.2. Elements are
required(non-null) and finite (no NaN, +Inf or -Inf).3. Elements are numeric or boolean Parquet primitives.
ConvertedType.LISTalongsideLogicalType.FINITE_VECTOR. Readers that fall back to the converted type read an ordinary LIST; readers that ignore both annotations see an unannotated group with a single repeated child group.Trade-offs:
Repetition/definition levels are still written. Reader and writer efficiency is left to the implementations.
Adding new float types (e.g. FP8, BF16) requires adding a primitive Parquet type. Packed
FLBA(num_elements type_width)storage would decouple this, at the cost of element-level encodings.Out of scope:
Vector indexes, quantisation and normalisation guarantees. Those need their own annotations rather than parameters on
FiniteVectorType.A more efficient physical type for storing fixed-sized lists may be proposed in the future and this logical type may be able to annotate it. This is intentionally left out of this proposal.
What changes are included in this PR?
Specifies the
FINITE_VECTORlogical type, its LIST representation, writer/reader requirements and element-level requirements.Do these changes have PoC implementations?
parquet-cpp / pyarrow: https://github.com/apache/arrow/pull/55348