diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java index 0684fe9097d5..51e33e544453 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/IndexLoadingConfig.java @@ -83,7 +83,6 @@ public class IndexLoadingConfig { private final Map _noDictionaryConfig = new HashMap<>(); private final Set _varLengthDictionaryColumns = new HashSet<>(); private Set _onHeapDictionaryColumns = new HashSet<>(); - private final Set _forwardIndexDisabledColumns = new HashSet<>(); private Map _bloomFilterConfigs = new HashMap<>(); private boolean _enableDynamicStarTreeCreation; private List _starTreeIndexConfigs; @@ -540,10 +539,6 @@ public Set getOnHeapDictionaryColumns() { return unmodifiable(_onHeapDictionaryColumns); } - public Set getForwardIndexDisabledColumns() { - return unmodifiable(_forwardIndexDisabledColumns); - } - public Map getBloomFilterConfigs() { return unmodifiable(_bloomFilterConfigs); } diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java index e655f9e470b9..f6dc1a159b35 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandler.java @@ -411,7 +411,7 @@ protected boolean createColumnV1Indices(String column) } // TODO: Support forward index disabled derived column - if (_indexLoadingConfig.getForwardIndexDisabledColumns().contains(column)) { + if (isForwardIndexDisabled(column)) { LOGGER.warn("Skip creating forward index disabled derived column: {}", column); if (errorOnFailure) { throw new UnsupportedOperationException( @@ -443,8 +443,8 @@ protected boolean createColumnV1Indices(String column) * Check and return whether the forward index is disabled for a given column */ protected boolean isForwardIndexDisabled(String column) { - return _indexLoadingConfig.getForwardIndexDisabledColumns() != null - && _indexLoadingConfig.getForwardIndexDisabledColumns().contains(column); + FieldIndexConfigs fieldIndexConfig = _indexLoadingConfig.getFieldIndexConfig(column); + return fieldIndexConfig != null && fieldIndexConfig.getConfig(StandardIndexes.forward()).isDisabled(); } /** diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java index 5488b2cf2790..55b8227d41af 100644 --- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java +++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/SegmentPreProcessorTest.java @@ -783,7 +783,7 @@ private void validateIndex(IndexType indexType, String column, int card assertFalse(reader.hasIndexFor(column, StandardIndexes.inverted())); } else { // Updating dictionary or forward index for existing columns not supported for v1 segments yet - if (segmentMetadata.getVersion() == SegmentVersion.v3) { + if (segmentMetadata.getVersion() == SegmentVersion.v3 || isAutoGenerated) { assertFalse(reader.hasIndexFor(column, StandardIndexes.forward())); } else { assertTrue(reader.hasIndexFor(column, StandardIndexes.forward())); diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandlerTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandlerTest.java deleted file mode 100644 index 47ea357894c8..000000000000 --- a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/BaseDefaultColumnHandlerTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.pinot.segment.local.segment.index.loader.defaultcolumn; - -import com.google.common.collect.ImmutableMap; -import java.io.File; -import java.nio.file.Files; -import java.util.Collections; -import java.util.concurrent.TimeUnit; -import org.apache.commons.io.FileUtils; -import org.apache.pinot.segment.local.segment.creator.SegmentTestUtils; -import org.apache.pinot.segment.local.segment.creator.impl.SegmentCreationDriverFactory; -import org.apache.pinot.segment.local.segment.index.SegmentMetadataImplTest; -import org.apache.pinot.segment.local.segment.index.loader.IndexLoadingConfig; -import org.apache.pinot.segment.local.segment.store.SegmentLocalFSDirectory; -import org.apache.pinot.segment.spi.creator.SegmentGeneratorConfig; -import org.apache.pinot.segment.spi.creator.SegmentIndexCreationDriver; -import org.apache.pinot.segment.spi.index.metadata.SegmentMetadataImpl; -import org.apache.pinot.segment.spi.store.SegmentDirectory; -import org.apache.pinot.spi.data.FieldSpec; -import org.apache.pinot.spi.data.Schema; -import org.apache.pinot.spi.utils.ReadMode; -import org.apache.pinot.util.TestUtils; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - - -public class BaseDefaultColumnHandlerTest { - private static final String AVRO_DATA = "data/test_data-mv.avro"; - - private File _indexDir; - private File _segmentDirectory; - private SegmentMetadataImpl _committedSegmentMetadata; - private SegmentDirectory.Writer _writer; - - @BeforeMethod - public void setUp() - throws Exception { - _indexDir = Files.createTempDirectory(SegmentMetadataImplTest.class.getName() + "_segmentDir").toFile(); - - final String filePath = - TestUtils.getFileFromResourceUrl(SegmentMetadataImplTest.class.getClassLoader().getResource(AVRO_DATA)); - - // intentionally changed this to TimeUnit.Hours to make it non-default for testing - final SegmentGeneratorConfig config = SegmentTestUtils - .getSegmentGenSpecWithSchemAndProjectedColumns(new File(filePath), _indexDir, "daysSinceEpoch", TimeUnit.HOURS, - "testTable"); - config.setSegmentNamePostfix("1"); - config.setTimeColumnName("daysSinceEpoch"); - final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); - driver.init(config); - driver.build(); - _segmentDirectory = new File(_indexDir, driver.getSegmentName()); - _committedSegmentMetadata = new SegmentMetadataImpl(_segmentDirectory); - _writer = new SegmentLocalFSDirectory(_segmentDirectory, _committedSegmentMetadata, ReadMode.mmap).createWriter(); - } - - @AfterMethod - public void tearDown() { - FileUtils.deleteQuietly(_segmentDirectory); - } - - @Test - public void testComputeDefaultColumnActionMapForCommittedSegment() { - // Dummy IndexLoadingConfig - IndexLoadingConfig indexLoadingConfig = new IndexLoadingConfig(); - - // Same schema - Schema schema0 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT).build(); - - BaseDefaultColumnHandler defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema0, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), Collections.EMPTY_MAP); - - // Add single-value dimension in the schema - Schema schema1 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column11", FieldSpec.DataType.INT) // add column11 - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT).build(); - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema1, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), - ImmutableMap.of("column11", BaseDefaultColumnHandler.DefaultColumnAction.ADD_DIMENSION)); - - // Add multi-value dimension in the schema - Schema schema2 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addMultiValueDimension("column11", FieldSpec.DataType.INT) // add column11 - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT).build(); - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema2, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), - ImmutableMap.of("column11", BaseDefaultColumnHandler.DefaultColumnAction.ADD_DIMENSION)); - - // Add metric in the schema - Schema schema3 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT) - .addMetric("column11", FieldSpec.DataType.INT).build(); // add column11 - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema3, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), - ImmutableMap.of("column11", BaseDefaultColumnHandler.DefaultColumnAction.ADD_METRIC)); - - // Add metric in the schema - Schema schema4 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT) - .addDateTime("column11", FieldSpec.DataType.INT, "1:HOURS:EPOCH", "1:HOURS").build(); // add column11 - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema4, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), - ImmutableMap.of("column11", BaseDefaultColumnHandler.DefaultColumnAction.ADD_DATE_TIME)); - - // Do not remove non-autogenerated column in the segmentMetadata - Schema schema5 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) // remove column2 - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT).build(); - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema5, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), Collections.EMPTY_MAP); - - // Do not update non-autogenerated column in the schema - Schema schema6 = - new Schema.SchemaBuilder().setSchemaName("testTable").addSingleValueDimension("column1", FieldSpec.DataType.INT) - .addSingleValueDimension("column2", FieldSpec.DataType.STRING) // update datatype - .addSingleValueDimension("column3", FieldSpec.DataType.STRING) - .addSingleValueDimension("column4", FieldSpec.DataType.STRING) - .addSingleValueDimension("column5", FieldSpec.DataType.STRING) - .addSingleValueDimension("column6", FieldSpec.DataType.INT) - .addSingleValueDimension("column7", FieldSpec.DataType.INT) - .addSingleValueDimension("column8", FieldSpec.DataType.INT) - .addSingleValueDimension("column9", FieldSpec.DataType.INT) - .addSingleValueDimension("column10", FieldSpec.DataType.INT) - .addSingleValueDimension("column13", FieldSpec.DataType.INT) - .addSingleValueDimension("count", FieldSpec.DataType.INT) - .addSingleValueDimension("daysSinceEpoch", FieldSpec.DataType.INT) - .addSingleValueDimension("weeksSinceEpochSunday", FieldSpec.DataType.INT).build(); - defaultColumnHandler = - new V3DefaultColumnHandler(_segmentDirectory, _committedSegmentMetadata, indexLoadingConfig, schema6, _writer); - Assert.assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), Collections.EMPTY_MAP); - } -} diff --git a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/DefaultColumnHandlerTest.java b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/DefaultColumnHandlerTest.java new file mode 100644 index 000000000000..dc008a487dfe --- /dev/null +++ b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/loader/defaultcolumn/DefaultColumnHandlerTest.java @@ -0,0 +1,134 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.segment.local.segment.index.loader.defaultcolumn; + +import java.io.File; +import java.net.URL; +import java.util.Map; +import org.apache.commons.io.FileUtils; +import org.apache.pinot.segment.local.segment.creator.SegmentTestUtils; +import org.apache.pinot.segment.local.segment.creator.impl.SegmentIndexCreationDriverImpl; +import org.apache.pinot.segment.local.segment.index.loader.IndexLoadingConfig; +import org.apache.pinot.segment.local.segment.index.loader.defaultcolumn.BaseDefaultColumnHandler.DefaultColumnAction; +import org.apache.pinot.segment.local.segment.store.SegmentLocalFSDirectory; +import org.apache.pinot.segment.spi.creator.SegmentGeneratorConfig; +import org.apache.pinot.segment.spi.store.SegmentDirectory; +import org.apache.pinot.spi.config.table.TableConfig; +import org.apache.pinot.spi.config.table.TableType; +import org.apache.pinot.spi.data.DateTimeFieldSpec; +import org.apache.pinot.spi.data.DimensionFieldSpec; +import org.apache.pinot.spi.data.FieldSpec.DataType; +import org.apache.pinot.spi.data.MetricFieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.utils.ReadMode; +import org.apache.pinot.spi.utils.builder.TableConfigBuilder; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + + +public class DefaultColumnHandlerTest { + private static final String RAW_TABLE_NAME = "testTable"; + private static final String SEGMENT_NAME = "testSegment"; + private static final File TEMP_DIR = + new File(FileUtils.getTempDirectory(), DefaultColumnHandlerTest.class.getSimpleName()); + private static final File INDEX_DIR = new File(TEMP_DIR, SEGMENT_NAME); + private static final String AVRO_DATA = "data/test_data-mv.avro"; + + private static final TableConfig TABLE_CONFIG = + new TableConfigBuilder(TableType.OFFLINE).setTableName(RAW_TABLE_NAME).build(); + + private Schema _schema; + private SegmentDirectory _segmentDirectory; + private SegmentDirectory.Writer _writer; + + @BeforeClass + public void setUp() + throws Exception { + FileUtils.deleteQuietly(TEMP_DIR); + + URL resourceUrl = getClass().getClassLoader().getResource(AVRO_DATA); + assertNotNull(resourceUrl); + File avroFile = new File(resourceUrl.getFile()); + _schema = SegmentTestUtils.extractSchemaFromAvroWithoutTime(avroFile); + SegmentGeneratorConfig config = new SegmentGeneratorConfig(TABLE_CONFIG, _schema); + config.setInputFilePath(avroFile.getAbsolutePath()); + config.setOutDir(TEMP_DIR.getAbsolutePath()); + config.setSegmentName(SEGMENT_NAME); + SegmentIndexCreationDriverImpl driver = new SegmentIndexCreationDriverImpl(); + driver.init(config); + driver.build(); + } + + @AfterClass + public void tearDown() { + FileUtils.deleteQuietly(TEMP_DIR); + } + + @Test + public void testComputeDefaultColumnActionMap() + throws Exception { + try (SegmentDirectory segmentDirectory = new SegmentLocalFSDirectory(INDEX_DIR, ReadMode.mmap); + SegmentDirectory.Writer writer = segmentDirectory.createWriter()) { + _segmentDirectory = segmentDirectory; + _writer = writer; + + // Same schema + testComputeDefaultColumnActionMap(Map.of()); + + // Add single-value dimension in the schema + _schema.addField(new DimensionFieldSpec("column11", DataType.INT, true)); + testComputeDefaultColumnActionMap(Map.of("column11", DefaultColumnAction.ADD_DIMENSION)); + _schema.removeField("column11"); + + // Add multi-value dimension in the schema + _schema.addField(new DimensionFieldSpec("column11", DataType.INT, false)); + testComputeDefaultColumnActionMap(Map.of("column11", DefaultColumnAction.ADD_DIMENSION)); + _schema.removeField("column11"); + + // Add metric in the schema + _schema.addField(new MetricFieldSpec("column11", DataType.INT)); + testComputeDefaultColumnActionMap(Map.of("column11", DefaultColumnAction.ADD_METRIC)); + _schema.removeField("column11"); + + // Add date-time in the schema + _schema.addField(new DateTimeFieldSpec("column11", DataType.INT, "EPOCH|HOURS", "1:HOURS")); + testComputeDefaultColumnActionMap(Map.of("column11", DefaultColumnAction.ADD_DATE_TIME)); + _schema.removeField("column11"); + + // Do not remove non-autogenerated column in the segmentMetadata + _schema.removeField("column2"); + testComputeDefaultColumnActionMap(Map.of()); + + // Do not update non-autogenerated column in the schema + _schema.addField(new DimensionFieldSpec("column2", DataType.STRING, true)); + testComputeDefaultColumnActionMap(Map.of()); + } + } + + private void testComputeDefaultColumnActionMap(Map expected) { + BaseDefaultColumnHandler defaultColumnHandler = + new V3DefaultColumnHandler(INDEX_DIR, _segmentDirectory.getSegmentMetadata(), + new IndexLoadingConfig(TABLE_CONFIG, _schema), _schema, _writer); + assertEquals(defaultColumnHandler.computeDefaultColumnActionMap(), expected); + } +}