Change dimensionToSchemaMap to dimensionSchemas and override ARRAY_INGEST_MODE to array (#16909)

A follow-up PR for #16864. Just renames dimensionToSchemaMap to dimensionSchemas and always overrides ARRAY_INGEST_MODE context value to array for MSQ compaction.
This commit is contained in:
Vishesh Garg 2024-08-20 10:30:24 +05:30 committed by GitHub
parent 2198001930
commit fb7103ccef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 20 deletions

View File

@ -1951,7 +1951,7 @@ public class ControllerImpl implements Controller
columnMappings, columnMappings,
isRollupQuery, isRollupQuery,
querySpec.getQuery(), querySpec.getQuery(),
destination.getDimensionToSchemaMap() destination.getDimensionSchemas()
); );
return new DataSchema( return new DataSchema(
@ -2127,11 +2127,11 @@ public class ControllerImpl implements Controller
final String outputColumnName, final String outputColumnName,
@Nullable final ColumnType queryType, @Nullable final ColumnType queryType,
QueryContext context, QueryContext context,
@Nullable Map<String, DimensionSchema> dimensionToSchemaMap @Nullable Map<String, DimensionSchema> dimensionSchemas
) )
{ {
if (dimensionToSchemaMap != null && dimensionToSchemaMap.containsKey(outputColumnName)) { if (dimensionSchemas != null && dimensionSchemas.containsKey(outputColumnName)) {
return dimensionToSchemaMap.get(outputColumnName); return dimensionSchemas.get(outputColumnName);
} }
// In case of ingestion, or when metrics are converted to dimensions when compaction is performed without rollup, // In case of ingestion, or when metrics are converted to dimensions when compaction is performed without rollup,
// we won't have an entry in the map. For those cases, use the default config. // we won't have an entry in the map. For those cases, use the default config.
@ -2150,7 +2150,7 @@ public class ControllerImpl implements Controller
final ColumnMappings columnMappings, final ColumnMappings columnMappings,
final boolean isRollupQuery, final boolean isRollupQuery,
final Query<?> query, final Query<?> query,
@Nullable final Map<String, DimensionSchema> dimensionToSchemaMap @Nullable final Map<String, DimensionSchema> dimensionSchemas
) )
{ {
// Log a warning unconditionally if arrayIngestMode is MVD, since the behaviour is incorrect, and is subject to // Log a warning unconditionally if arrayIngestMode is MVD, since the behaviour is incorrect, and is subject to
@ -2237,13 +2237,13 @@ public class ControllerImpl implements Controller
outputColumnName, outputColumnName,
type, type,
query.context(), query.context(),
dimensionToSchemaMap dimensionSchemas
); );
} else { } else {
// complex columns only // complex columns only
if (DimensionHandlerUtils.DIMENSION_HANDLER_PROVIDERS.containsKey(type.getComplexTypeName())) { if (DimensionHandlerUtils.DIMENSION_HANDLER_PROVIDERS.containsKey(type.getComplexTypeName())) {
dimensions.add( dimensions.add(
getDimensionSchema(outputColumnName, type, query.context(), dimensionToSchemaMap) getDimensionSchema(outputColumnName, type, query.context(), dimensionSchemas)
); );
} else if (!isRollupQuery) { } else if (!isRollupQuery) {
aggregators.add(new PassthroughAggregatorFactory(outputColumnName, type.getComplexTypeName())); aggregators.add(new PassthroughAggregatorFactory(outputColumnName, type.getComplexTypeName()));
@ -2255,7 +2255,7 @@ public class ControllerImpl implements Controller
outputColumnName, outputColumnName,
type, type,
query.context(), query.context(),
dimensionToSchemaMap dimensionSchemas
); );
} }
} }
@ -2283,14 +2283,14 @@ public class ControllerImpl implements Controller
String outputColumn, String outputColumn,
ColumnType type, ColumnType type,
QueryContext context, QueryContext context,
Map<String, DimensionSchema> dimensionToSchemaMap Map<String, DimensionSchema> dimensionSchemas
) )
{ {
if (outputColumnAggregatorFactories.containsKey(outputColumn)) { if (outputColumnAggregatorFactories.containsKey(outputColumn)) {
aggregators.add(outputColumnAggregatorFactories.get(outputColumn)); aggregators.add(outputColumnAggregatorFactories.get(outputColumn));
} else { } else {
dimensions.add( dimensions.add(
getDimensionSchema(outputColumn, type, context, dimensionToSchemaMap) getDimensionSchema(outputColumn, type, context, dimensionSchemas)
); );
} }
} }

View File

@ -503,7 +503,8 @@ public class MSQCompactionRunner implements CompactionRunner
context.putIfAbsent(QueryContexts.FINALIZE_KEY, false); context.putIfAbsent(QueryContexts.FINALIZE_KEY, false);
// Only scalar or array-type dimensions are allowed as grouping keys. // Only scalar or array-type dimensions are allowed as grouping keys.
context.putIfAbsent(GroupByQueryConfig.CTX_KEY_ENABLE_MULTI_VALUE_UNNESTING, false); context.putIfAbsent(GroupByQueryConfig.CTX_KEY_ENABLE_MULTI_VALUE_UNNESTING, false);
context.putIfAbsent(MultiStageQueryContext.CTX_ARRAY_INGEST_MODE, "array"); // Always override CTX_ARRAY_INGEST_MODE since it can otherwise lead to mixed ARRAY and MVD types for a column.
context.put(MultiStageQueryContext.CTX_ARRAY_INGEST_MODE, "array");
return context; return context;
} }

View File

@ -52,7 +52,7 @@ public class DataSourceMSQDestination implements MSQDestination
private final List<Interval> replaceTimeChunks; private final List<Interval> replaceTimeChunks;
@Nullable @Nullable
private final Map<String, DimensionSchema> dimensionToSchemaMap; private final Map<String, DimensionSchema> dimensionSchemas;
@JsonCreator @JsonCreator
public DataSourceMSQDestination( public DataSourceMSQDestination(
@ -60,14 +60,14 @@ public class DataSourceMSQDestination implements MSQDestination
@JsonProperty("segmentGranularity") Granularity segmentGranularity, @JsonProperty("segmentGranularity") Granularity segmentGranularity,
@JsonProperty("segmentSortOrder") @Nullable List<String> segmentSortOrder, @JsonProperty("segmentSortOrder") @Nullable List<String> segmentSortOrder,
@JsonProperty("replaceTimeChunks") @Nullable List<Interval> replaceTimeChunks, @JsonProperty("replaceTimeChunks") @Nullable List<Interval> replaceTimeChunks,
@JsonProperty("dimensionToSchemaMap") @Nullable Map<String, DimensionSchema> dimensionToSchemaMap @JsonProperty("dimensionSchemas") @Nullable Map<String, DimensionSchema> dimensionSchemas
) )
{ {
this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource"); this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource");
this.segmentGranularity = Preconditions.checkNotNull(segmentGranularity, "segmentGranularity"); this.segmentGranularity = Preconditions.checkNotNull(segmentGranularity, "segmentGranularity");
this.segmentSortOrder = segmentSortOrder != null ? segmentSortOrder : Collections.emptyList(); this.segmentSortOrder = segmentSortOrder != null ? segmentSortOrder : Collections.emptyList();
this.replaceTimeChunks = replaceTimeChunks; this.replaceTimeChunks = replaceTimeChunks;
this.dimensionToSchemaMap = dimensionToSchemaMap; this.dimensionSchemas = dimensionSchemas;
if (replaceTimeChunks != null) { if (replaceTimeChunks != null) {
// Verify that if replaceTimeChunks is provided, it is nonempty. // Verify that if replaceTimeChunks is provided, it is nonempty.
@ -138,9 +138,9 @@ public class DataSourceMSQDestination implements MSQDestination
@Nullable @Nullable
@JsonProperty @JsonProperty
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public Map<String, DimensionSchema> getDimensionToSchemaMap() public Map<String, DimensionSchema> getDimensionSchemas()
{ {
return dimensionToSchemaMap; return dimensionSchemas;
} }
/** /**
@ -177,13 +177,13 @@ public class DataSourceMSQDestination implements MSQDestination
&& Objects.equals(segmentGranularity, that.segmentGranularity) && Objects.equals(segmentGranularity, that.segmentGranularity)
&& Objects.equals(segmentSortOrder, that.segmentSortOrder) && Objects.equals(segmentSortOrder, that.segmentSortOrder)
&& Objects.equals(replaceTimeChunks, that.replaceTimeChunks) && Objects.equals(replaceTimeChunks, that.replaceTimeChunks)
&& Objects.equals(dimensionToSchemaMap, that.dimensionToSchemaMap); && Objects.equals(dimensionSchemas, that.dimensionSchemas);
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
return Objects.hash(dataSource, segmentGranularity, segmentSortOrder, replaceTimeChunks, dimensionToSchemaMap); return Objects.hash(dataSource, segmentGranularity, segmentSortOrder, replaceTimeChunks, dimensionSchemas);
} }
@Override @Override
@ -194,7 +194,7 @@ public class DataSourceMSQDestination implements MSQDestination
", segmentGranularity=" + segmentGranularity + ", segmentGranularity=" + segmentGranularity +
", segmentSortOrder=" + segmentSortOrder + ", segmentSortOrder=" + segmentSortOrder +
", replaceTimeChunks=" + replaceTimeChunks + ", replaceTimeChunks=" + replaceTimeChunks +
", dimensionToSchemaMap=" + dimensionToSchemaMap + ", dimensionSchemas=" + dimensionSchemas +
'}'; '}';
} }

View File

@ -35,7 +35,7 @@ public class DataSourceMSQDestinationTest
public void testEquals() public void testEquals()
{ {
EqualsVerifier.forClass(DataSourceMSQDestination.class) EqualsVerifier.forClass(DataSourceMSQDestination.class)
.withNonnullFields("dataSource", "segmentGranularity", "segmentSortOrder", "dimensionToSchemaMap") .withNonnullFields("dataSource", "segmentGranularity", "segmentSortOrder", "dimensionSchemas")
.withPrefabValues( .withPrefabValues(
Map.class, Map.class,
ImmutableMap.of( ImmutableMap.of(