Skip to content

Commit ec668a8

Browse files
committed
use effective state for dimspec and indexspec for reindexing fingerprinting
1 parent 7768a8a commit ec668a8

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

processing/src/main/java/org/apache/druid/data/input/impl/DimensionSchema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public DimensionHandler getDimensionHandler()
200200

201201
/**
202202
* Computes the 'effective' {@link DimensionSchema}, allowing columns which provide mechanisms for customizing storage
203-
* format to fill in values from the segment level {@link IndexSpec} defaults. This is useful for comparising the
203+
* format to fill in values from the segment level {@link IndexSpec} defaults. This is useful for comparing the
204204
* operator explicitly defined schema with the 'effective' schema that was written to the segments for things like
205205
* comparing compaction state.
206206
*/

server/src/main/java/org/apache/druid/server/coordinator/DataSourceCompactionConfig.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import java.util.Arrays;
4141
import java.util.List;
4242
import java.util.Map;
43+
import java.util.stream.Collectors;
4344

4445
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = InlineSchemaDataSourceCompactionConfig.class)
4546
@JsonSubTypes(value = {
@@ -101,34 +102,39 @@ public interface DataSourceCompactionConfig
101102

102103
/**
103104
* Converts this compaction config to a {@link CompactionState}.
105+
* <p>
106+
* For IndexSpec and DimensionsSpec, we convert to their effective specs so that the fingerprint and associated state
107+
* reflect the actual layout of the segments after compaction (with all missing defaults not included in the compaction
108+
* config filled in). This is consistent with how {@link org.apache.druid.timeline.DataSegment#lastCompactionState }
109+
* has been computed historically.
104110
*/
105111
default CompactionState toCompactionState()
106112
{
107113
ClientCompactionTaskQueryTuningConfig tuningConfig = ClientCompactionTaskQueryTuningConfig.from(this);
108114

109-
// 1. PartitionsSpec - reuse existing method
110115
PartitionsSpec partitionsSpec = CompactionStatus.findPartitionsSpecFromConfig(tuningConfig);
111116

112-
// 2. DimensionsSpec
117+
IndexSpec indexSpec = tuningConfig.getIndexSpec() == null
118+
? IndexSpec.getDefault().getEffectiveSpec()
119+
: tuningConfig.getIndexSpec().getEffectiveSpec();
120+
113121
DimensionsSpec dimensionsSpec = null;
114122
if (getDimensionsSpec() != null && getDimensionsSpec().getDimensions() != null) {
115-
dimensionsSpec = new DimensionsSpec(getDimensionsSpec().getDimensions());
123+
dimensionsSpec = DimensionsSpec.builder()
124+
.setDimensions(
125+
getDimensionsSpec().getDimensions()
126+
.stream()
127+
.map(dim -> dim.getEffectiveSchema(indexSpec))
128+
.collect(Collectors.toList())
129+
).build();
116130
}
117131

118-
// 3. Metrics
119132
List<AggregatorFactory> metricsSpec = getMetricsSpec() == null
120133
? null
121134
: Arrays.asList(getMetricsSpec());
122135

123-
// 4. Transform
124136
CompactionTransformSpec transformSpec = getTransformSpec();
125137

126-
// 5. IndexSpec
127-
IndexSpec indexSpec = tuningConfig.getIndexSpec() == null
128-
? IndexSpec.getDefault()
129-
: tuningConfig.getIndexSpec();
130-
131-
// 6. GranularitySpec
132138
GranularitySpec granularitySpec = null;
133139
if (getGranularitySpec() != null) {
134140
UserCompactionTaskGranularityConfig userGranularityConfig = getGranularitySpec();
@@ -140,7 +146,6 @@ default CompactionState toCompactionState()
140146
);
141147
}
142148

143-
// 7. Projections
144149
List<AggregateProjectionSpec> projections = getProjections();
145150

146151
return new CompactionState(

0 commit comments

Comments
 (0)