This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new b3af476b83 Prevent inverted index on a non dictionary column in table
config (#12043)
b3af476b83 is described below
commit b3af476b8314f7201e00c2ccd94ad720634f9f8a
Author: 9aman <[email protected]>
AuthorDate: Thu Nov 23 05:06:17 2023 +0530
Prevent inverted index on a non dictionary column in table config (#12043)
---
.../pinot/segment/local/utils/TableConfigUtils.java | 5 +++++
.../pinot/segment/local/utils/TableConfigUtilsTest.java | 15 +++++++++++++++
2 files changed, 20 insertions(+)
diff --git
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
index 6290f5f913..ebea84c455 100644
---
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
+++
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/utils/TableConfigUtils.java
@@ -1156,6 +1156,11 @@ public final class TableConfigUtils {
&& fieldConfigColSpec.getDataType().getStoredType() ==
DataType.STRING,
"FST Index is only supported for single value string
columns");
break;
+ case INVERTED:
+ Preconditions.checkArgument(fieldConfig.getEncodingType() ==
FieldConfig.EncodingType.DICTIONARY,
+ "Cannot create an Inverted Index on column: " +
fieldConfig.getName() + ", specified as "
+ + "a non dictionary column");
+ break;
case TEXT:
Preconditions.checkState(fieldConfigColSpec.getDataType().getStoredType() ==
DataType.STRING,
"TEXT Index is only supported for string columns");
diff --git
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
index 1b68bb8a8f..7653ff7636 100644
---
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
+++
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java
@@ -1230,6 +1230,21 @@ public class TableConfigUtilsTest {
"Cannot create an Inverted index on column myCol2 specified in the "
+ "noDictionaryColumns config");
}
+ // Tests the case when the field-config list marks a column as raw
(non-dictionary) and enables
+ // inverted index on it
+ tableConfig = new
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).build();
+ try {
+ FieldConfig fieldConfig = new FieldConfig.Builder("myCol2")
+ .withIndexTypes(Arrays.asList(FieldConfig.IndexType.INVERTED))
+ .withEncodingType(FieldConfig.EncodingType.RAW).build();
+ tableConfig.setFieldConfigList(Arrays.asList(fieldConfig));
+ TableConfigUtils.validate(tableConfig, schema);
+ Assert.fail("Should not be able to disable dictionary but keep inverted
index");
+ } catch (Exception e) {
+ Assert.assertEquals(e.getMessage(),
+ "Cannot create an Inverted Index on column: myCol2, specified as a
non dictionary column");
+ }
+
tableConfig = new
TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME)
.setNoDictionaryColumns(Arrays.asList("myCol2")).build();
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]