Repository navigation
[core] Support array row fields in multivalue indexes - #11706
XiaoHongbo-Hope wants to merge 32 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
I reproduced three cases where matching rows are dropped on ce90fe82c4.
| Optional.of(GlobalIndexResult.createEmpty())); | ||
| } | ||
| DataField child = ((RowType) elementType).getField(fieldId); | ||
| KeySerializer serializer = KeySerializer.create(child.type()); |
There was a problem hiding this comment.
[P1] Check the indexed child type after primary-key schema evolution
On a primary-key table with deletion vectors enabled, set global-index.multivalue.index-columns=tags and multivalue-index.fields=tag_id. Write id=1 with tag_id=7 in tags ARRAY<ROW<tag_id INT>> and a second row with tag_id=9. Compact to build the index, then use SchemaChange.updateColumnType to widen tags.element.tag_id to BIGINT without rewriting the data files.
arrayFieldContains(1, "tag_id", 7L) returned [] with the existing index and [1] with global-index.enabled=false. The child ID survives widening, so the reader uses the current 8-byte key encoding against postings written with the old 4-byte encoding. Please validate the child type against the build schema and fall back to reading the affected rows until the index is rebuilt.
| @Override | ||
| public CompletableFuture<Optional<GlobalIndexResult>> visitArrayField( | ||
| FieldRef fieldRef, int fieldId, LeafFunction function, List<Object> literals) { | ||
| return unionAsync(reader -> reader.visitArrayField(fieldRef, fieldId, function, literals)); |
There was a problem hiding this comment.
[P1] Preserve ranked matches from ranges that index the requested child
On a Data Evolution table, write two documents that match the same full-text query. Give both a tags element with key=1 and value=7. Build a full-text index over both rows and multivalue shards for row IDs 0 and 1 with multivalue-index.fields=key and key,value, respectively.
With scalar-index.prefilter.search-mode=fast, a full-text search filtered by arrayFieldContains(2, "value", 7) returned [], even though row ID 1 is fully covered and should be returned. With full or detail and the default global-index.filter.refine-from-data=false, the conjunction of arrayFieldContains(2, "key", 1) and arrayFieldContains(2, "value", 7) also returned []. The expected row IDs were [0, 1].
The first shard returns Optional.empty() for value, so unionAsync discards the exact result from the second shard. Coverage tracked by the top-level tags column also hides the first shard's value gap from full and detail. Please track coverage by child and row-ID range so the search can keep exact matches and apply the configured fallback to uncovered rows.
| RowType element = (RowType) ((ArrayType) field.type()).getElementType(); | ||
| DataField child = element.getField(fieldName); | ||
| DataType childType = child.type(); | ||
| List<Object> normalized = new ArrayList<>(literals.size()); |
There was a problem hiding this comment.
[P2] Normalize Decimal literals from the generic Transform overloads
On a Data Evolution table with global-index.query-in-reader.enabled=true, store 1.20 in an indexed DECIMAL(10,2) array child on the row with id=7. Build the predicate through arrayContains(Transform, Object) with an ArrayFieldTransform and Decimal.fromBigDecimal(new BigDecimal("1.200"), 10, 3).
The original IndexQuerySplit returned [7]. Serializing and deserializing only that split with InstantiationUtil returned [] while using the same reader filter. The generic overload bypasses the normalization here, so the literal's unscaled value of 1200 is read at the child field's scale 2 and becomes 12.00. The index lookup prunes the matching row before the reader can filter it.
Please normalize membership literals in the shared predicate construction path and add a split round-trip test through the generic overload.
|
Reuse the existing array predicates. I’d expose the child projection through a builder method such as Transform tagIds = predicates.arrayField(tagsFieldIndex, "tag_id");
Predicate filter = predicates.arrayContains(tagIds, 123L);
Make indexed child selection column-scoped. I’d make ALTER TABLE db.my_table SET (
'fields.tags.index-options' = '{"fields":"tag_id,tag_value"}',
'fields.actors.index-options' = '{"fields":"role"}'
);The sorted writer already uses |
Purpose
Support membership queries on selected scalar children of
ARRAY<ROW>with multivalue indexes. ExposearrayField(index, child)and reuse existing array predicates;arrayContains("tags.id", value)is a shorthand.Select children per column with
fields.<column>.index-options, for example{"fields":"id,value"}. Initial builds and incremental refreshes use the same configuration. Separate predicates may match different array elements.Retain row filtering and IndexedSplit v1. Build indexes with Flink; Spark rejects this index shape.
Validation
308 targeted Common/Core tests passed, covering membership, serialization, schema evolution, and full-text/vector filtering with mixed child-index coverage. Checkstyle, Spotless and
git diff --checkpassed. Flink initial and incremental builds were also tested.Seven regression cases fail on the previous head and pass with the fixes: primary-key child type widening and mixed child coverage in fast/full/detail searches.