xiangfu0 opened a new pull request, #18406:
URL: https://github.com/apache/pinot/pull/18406
## Summary
Adds an opt-in per-column override (`FieldConfig.consumingOverride`) that
lets a realtime table column have a richer in-memory shape on the **mutable
consuming segment** than what is persisted on disk.
**Typical use case:** keep the table in raw encoding (smaller storage, no
dictionary on disk) while giving the *consuming* segment a dictionary +
inverted index for fast filtering during the consumption window. The
committed/immutable segment uses the un-overridden table config — the override
never leaks to disk.
### Example
```json
{
\"fieldConfigList\": [{
\"name\": \"userId\",
\"encodingType\": \"RAW\",
\"consumingOverride\": {
\"encodingType\": \"DICTIONARY\",
\"indexTypes\": [\"INVERTED\"]
}
}],
\"tableIndexConfig\": {
\"noDictionaryColumns\": [\"userId\"]
}
}
```
## Architecture
- **SPI**: `FieldConfig.consumingOverride` is an optional `JsonNode`
mirroring a partial `FieldConfig` (allowed keys: `encodingType`, `indexTypes`,
`indexes`, `compressionCodec`). Backward compatible — older clients see it as
an unknown property and ignore it via
`@JsonIgnoreProperties(ignoreUnknown=true)` on `BaseJsonConfig`.
- **Single dispatch point**:
`TableConfigUtils.buildConsumingSegmentConfigBuilder` is used by both
`RealtimeSegmentDataManager` and `StatelessRealtimeSegmentWriter`.
- **No override**: returns the existing `IndexLoadingConfig`-driven
Builder unchanged (zero behavior change for tables that don't opt in).
- **With override**: routes the override-applied `TableConfig` back
through a new `IndexLoadingConfig` (with a defensive schema clone) so instance
config, tier overlay, and schema-derived timestamp index materialization all
flow through unchanged.
- **On `RuntimeException`** (a misconfiguration that slipped past
validate): logs and falls back to the persisted shape so consumption keeps
making forward progress.
- **Merge utility**: `TableConfigUtils.applyConsumingOverrides` deep-copies
the JSON tree before mutating to avoid aliasing into the cached `TableConfig`
(other server threads may be reading it concurrently).
- **Validation**: shared `enforceConsumingOverrideInvariants` helper used by
both validate-time and apply-time paths so the rules can't drift. Rejects
non-realtime tables, sorted columns, partition columns, and unknown override
keys. Merged shape is re-validated with diagnostics that point back to the
originating `consumingOverride`.
- **Scrub policy**: deny-list — any per-column string-array in
`tableIndexConfig` (e.g. `invertedIndexColumns`, `noDictionaryColumns`, ...) is
scrubbed for overridden columns. Object-keyed maps and structurally-tied
collections (`sortedColumn`, `starTreeIndexConfigs`, `tierOverwrites`) are
intentionally left alone to avoid over-scrubbing feature configs whose keys
could collide with column names.
## SPI change note
This adds a new optional field to `FieldConfig` (in `pinot-spi`). Plugin
teams that build `FieldConfig` directly via the canonical constructor will see
a new 10-arg `@JsonCreator` constructor; the previous 9-arg signature is
preserved as a `@Deprecated` overload for source/binary compatibility.
Mixed-version clusters: an older server reading a controller-written
`consumingOverride` silently drops the unknown field and behaves as if no
override exists.
## Test plan
- [x] 23 unit tests in `TableConfigConsumingOverrideTest` covering:
- merge semantics (encoding/indexes/compressionCodec replacement, scrub of
legacy per-column lists)
- input-mutation guard (cached `TableConfig` byte-for-byte unchanged after
merge)
- idempotence
- validation rules (REALTIME-only, sorted-column rejection,
partition-column rejection, allowlist enforcement)
- validate-path *and* apply-path enforcement
- dispatch helper (no-override, valid override, fallback on failure)
- JSON round-trip
- legacy `FieldConfig` JSON without `consumingOverride` still deserializes
- [x] End-to-end converter test
(`RealtimeSegmentConverterTest.testConsumingOverrideKeepsRawShapeOnImmutableSegment`)
verifies the immutable segment retains the persisted RAW shape with no
inverted index, even when the consuming segment was built with `DICTIONARY +
INVERTED`.
- [x] Spotless / Checkstyle / License all pass.
- [x] No regression in `TableConfigUtilsTest` (56 tests),
`IndexLoadingConfigTest` (3), `BaseTableDataManagerTest` (25),
`RealtimeSegmentConverterTest` (161).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]