Vamsi-klu commented on code in PR #18977:
URL: https://github.com/apache/pinot/pull/18977#discussion_r4648309869
##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/refreshsegment/RefreshSegmentTaskExecutor.java:
##########
@@ -196,6 +371,60 @@ private static SegmentGeneratorConfig
getSegmentGeneratorConfig(File workingDir,
return config;
}
+ private static void preserveOriginalColumnMetadata(File refreshedSegmentDir,
+ Map<String, ColumnMetadata> originalMetadata, Set<String>
transformColumnsToRecompute,
+ Set<String> changedTransformColumns, Map<String, String>
transformFunctionByColumn,
+ Set<String> replayDefaultColumns)
+ throws Exception {
+ if (originalMetadata.isEmpty() && replayDefaultColumns.isEmpty()) {
+ return;
+ }
+ var properties =
SegmentMetadataUtils.getPropertiesConfiguration(refreshedSegmentDir);
+ for (Map.Entry<String, ColumnMetadata> entry :
originalMetadata.entrySet()) {
+ String column = entry.getKey();
+ ColumnMetadata columnMetadata = entry.getValue();
+ properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
Review Comment:
If replay fills the whole column with the schema default after a transform
is removed, the metadata marks the column as auto-generated and clears the
transform. I tested this on one segment. I removed the transform, changed the
default, then put the transform back and checked the values at each step.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-plugins/pinot-minion-tasks/pinot-minion-builtin-tasks/src/main/java/org/apache/pinot/plugin/minion/tasks/refreshsegment/RefreshSegmentTaskExecutor.java:
##########
@@ -196,6 +374,74 @@ private static SegmentGeneratorConfig
getSegmentGeneratorConfig(File workingDir,
return config;
}
+ private static void preserveOriginalColumnMetadata(File refreshedSegmentDir,
+ Map<String, ColumnMetadata> originalMetadata, Set<String>
transformColumnsToRecompute,
+ Set<String> changedTransformColumns, Map<String, String>
transformFunctionByColumn,
+ Set<String> replayDefaultColumns)
+ throws Exception {
+ if (originalMetadata.isEmpty() && replayDefaultColumns.isEmpty()) {
+ return;
+ }
+ var properties =
SegmentMetadataUtils.getPropertiesConfiguration(refreshedSegmentDir);
+ for (Map.Entry<String, ColumnMetadata> entry :
originalMetadata.entrySet()) {
+ String column = entry.getKey();
+ ColumnMetadata columnMetadata = entry.getValue();
+ // A column whose transform was removed was just regenerated from the
schema default, which makes it a default
+ // column even if the transform ran at ingestion time: a later
default-value change must regenerate it.
+ boolean regeneratedFromDefault =
+ changedTransformColumns.contains(column) &&
transformFunctionByColumn.get(column) == null;
+ properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+ V1Constants.MetadataKeys.Column.IS_AUTO_GENERATED),
+ regeneratedFromDefault || columnMetadata.isAutoGenerated());
+ if (changedTransformColumns.contains(column)) {
+ // A removed transform is deliberately regenerated as schema default
values. Record that known no-transform
+ // state so adding an expression later is distinguishable from legacy
metadata with unknown provenance.
+ if (transformFunctionByColumn.get(column) == null) {
+ BaseSegmentCreator.addTransformFunction(properties, column, null);
+ }
+ } else if (!transformColumnsToRecompute.contains(column)) {
+ // Recomputed ancestors keep the provenance emitted by this build. In
particular, a continue-on-error fallback
+ // must not be overwritten with the old trusted fingerprint.
+ if (columnMetadata.getTransformFunctionProvenanceVersion() ==
ColumnMetadata.UNAVAILABLE) {
+
properties.clearProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+ V1Constants.MetadataKeys.Column.TRANSFORM_FUNCTION));
+
properties.clearProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+ V1Constants.MetadataKeys.Column.TRANSFORM_FUNCTION_BASE64));
+
properties.clearProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+
V1Constants.MetadataKeys.Column.TRANSFORM_FUNCTION_PROVENANCE_VERSION));
+
properties.clearProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+ V1Constants.MetadataKeys.Column.TRANSFORM_FUNCTION_FINGERPRINT));
+ } else {
+ BaseSegmentCreator.addTransformFunction(properties, column,
columnMetadata.getTransformFunction(),
+ columnMetadata.getTransformFunctionFingerprint());
+ // Preserve the exact provenance version. addTransformFunction()
normally infers the version for new writes,
+ // but an unrelated refresh must not silently upgrade or downgrade
metadata it did not regenerate.
+
properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
+
V1Constants.MetadataKeys.Column.TRANSFORM_FUNCTION_PROVENANCE_VERSION),
+ columnMetadata.getTransformFunctionProvenanceVersion());
+ }
+ }
+ }
+ for (String column : replayDefaultColumns) {
+ // Row replay supplies this value before expressions, but the regular
segment-generation path otherwise records
+ // it like a source field. Preserve its default-column identity so a
later structural or transform change can
+ // regenerate it instead of treating the previously materialized default
as authoritative input.
+ properties.setProperty(V1Constants.MetadataKeys.Column.getKeyFor(column,
Review Comment:
Refresh now checks what the enricher actually supplied. An explicit null
counts too. It only marks the column as fully defaulted if replay supplied the
default for every row. I tested a column with a mix of enriched and defaulted
rows, then changed the schema default and checked the values after reload.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java:
##########
@@ -414,6 +442,19 @@ Map<String, DefaultColumnAction>
computeDefaultColumnActionMap() {
return defaultColumnActionMap;
}
+ /// Returns `true` when a column with known provenance was generated by a
different transform expression than the one
+ /// configured now. Legacy columns have no provenance marker and are left
untouched because their generating
+ /// expression is unknowable. A null expression with known provenance is a
known no-transform state.
+ ///
+ /// The column is then regenerated like any other updated column, in
[#orderByDependencies] order, so a changed
+ /// input is rebuilt before the columns that read it. A dependent whose own
expression did not change is not
+ /// regenerated, which is why metadata written here records the expression
without a dependency fingerprint and stays
+ /// provenance version 1. Dependency-closed version-2 provenance is written
only by full record replay.
+ private boolean isTransformFunctionChanged(String column, ColumnMetadata
columnMetadata) {
Review Comment:
Changing `A` now rebuilds the derived columns that depend on it. Reload does
that in dependency order so each column sees the new values from its inputs,
then invalidates the affected indexes before installing the replacements. I
changed only `A` in the test and checked `B` and a later dependent after
reopening the segment. If the server needs an input that isn't stored, it keeps
the old chain in place for record replay.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java:
##########
@@ -348,6 +368,8 @@ Map<String, DefaultColumnAction>
computeDefaultColumnActionMap() {
defaultColumnActionMap.put(column,
DefaultColumnAction.UPDATE_DIMENSION_DEFAULT_VALUE);
} else if (isSingleValueInMetadata != isSingleValueInSchema) {
defaultColumnActionMap.put(column,
DefaultColumnAction.UPDATE_DIMENSION_NUMBER_OF_VALUES);
+ } else if (isTransformFunctionChanged(column, columnMetadata)) {
Review Comment:
The handler now builds the replacements before touching the old indexes or
publishing metadata. With `errorOnColumnBuildFailure=false`, a conversion error
leaves the old values and indexes in place. If a write fails while installing
the replacements, reload restores the backup.
I tested reopening the segment after a conversion failure. In a separate
test I forced a write failure, checked that the original segment came back on
disk, and retried the reload successfully.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/ColumnMetadata.java:
##########
@@ -85,6 +85,19 @@ default Map<String, DataType> getSparseKeyTypes() {
return null;
}
+ /// Returns the transform function expression used to generate the column,
if persisted in the segment metadata.
+ @Nullable
+ String getTransformFunction();
Review Comment:
I restored the default return values of `null`, `UNAVAILABLE`, and `null`.
The mapped implementation still reads the stored values.
I tried this with a class compiled against the old SPI. Its first new getter
call threw `AbstractMethodError` with the published interface. That same class
file could call all three getters with the defaults back. I also checked that
the old source compiles against the updated interface.
Drafted-by: OpenAI Codex (GPT-6); reviewed by @Vamsi-klu before posting
--
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]