xiangfu0 commented on code in PR #8343:
URL: https://github.com/apache/pinot/pull/8343#discussion_r846339619
##########
pinot-segment-spi/src/main/java/org/apache/pinot/segment/spi/creator/SegmentGeneratorConfig.java:
##########
@@ -202,6 +207,33 @@ public SegmentGeneratorConfig(TableConfig tableConfig,
Schema schema) {
}
}
+ public static Schema updateSchemaWithTimestampIndexes(Schema schema,
+ Map<String, List<TimestampIndexGranularity>> timestampIndexConfigs) {
+ if (timestampIndexConfigs.isEmpty()) {
+ return schema;
+ }
+ List<FieldSpec> timestampColumnWithGranularityFieldSpecs = new
ArrayList<>();
+ for (String columnName : timestampIndexConfigs.keySet()) {
+ Preconditions.checkState(schema.hasColumn(columnName),
+ "Cannot create Timestamp index for column: %s because it is not in
schema", columnName);
+ timestampIndexConfigs.get(columnName).stream().filter(granularity ->
!schema.hasColumn(
+ TimestampIndexGranularity.getColumnNameWithGranularity(columnName,
granularity))).forEach(
+ granularity -> timestampColumnWithGranularityFieldSpecs.add(
+
TimestampIndexGranularity.getFieldSpecForTimestampColumnWithGranularity(
+ schema.getFieldSpecFor(columnName), granularity)));
+ }
+ if (timestampColumnWithGranularityFieldSpecs.isEmpty()) {
+ return schema;
+ }
+ Schema newSchema = new Schema.SchemaBuilder()
Review Comment:
The issue here is for quickstart/batch ingestion, we do parallel segment
build, there will be a race condition as multiple threads may want to modify
this schema at the same time. AddField will fail for re-adding same column name.
Another alternative is to add synchronize for this call.
--
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]