You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by sn...@apache.org on 2020/09/23 19:14:10 UTC

[incubator-pinot] branch master updated: Add validation for segment partition config column names (#6049)

This is an automated email from the ASF dual-hosted git repository.

snlee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new a88e05e  Add validation for segment partition config column names (#6049)
a88e05e is described below

commit a88e05ef9467f8d7200e45ec885508b8ad6d2f61
Author: Seunghyun Lee <sn...@linkedin.com>
AuthorDate: Wed Sep 23 12:14:02 2020 -0700

    Add validation for segment partition config column names (#6049)
---
 .../org/apache/pinot/core/util/TableConfigUtils.java   |  7 +++++++
 .../apache/pinot/core/util/TableConfigUtilsTest.java   | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/pinot-core/src/main/java/org/apache/pinot/core/util/TableConfigUtils.java b/pinot-core/src/main/java/org/apache/pinot/core/util/TableConfigUtils.java
index c91c7f9..755aa7e 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/util/TableConfigUtils.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/util/TableConfigUtils.java
@@ -280,6 +280,13 @@ public final class TableConfigUtils {
         columnNameToConfigMap.put(columnName, "Var Length Column Config");
       }
     }
+    if (indexingConfig.getSegmentPartitionConfig() != null
+        && indexingConfig.getSegmentPartitionConfig().getColumnPartitionMap() != null) {
+      for (String columnName : indexingConfig.getSegmentPartitionConfig().getColumnPartitionMap().keySet()) {
+        columnNameToConfigMap.put(columnName, "Segment Partition Config");
+      }
+    }
+
     List<StarTreeIndexConfig> starTreeIndexConfigList = indexingConfig.getStarTreeIndexConfigs();
     if (starTreeIndexConfigList != null) {
       for (StarTreeIndexConfig starTreeIndexConfig : starTreeIndexConfigList) {
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/util/TableConfigUtilsTest.java b/pinot-core/src/test/java/org/apache/pinot/core/util/TableConfigUtilsTest.java
index 32e658e..fc9b29b 100644
--- a/pinot-core/src/test/java/org/apache/pinot/core/util/TableConfigUtilsTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/core/util/TableConfigUtilsTest.java
@@ -21,9 +21,13 @@ package org.apache.pinot.core.util;
 import com.google.common.collect.Lists;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 import org.apache.pinot.common.tier.TierFactory;
+import org.apache.pinot.spi.config.table.ColumnPartitionConfig;
 import org.apache.pinot.spi.config.table.FieldConfig;
 import org.apache.pinot.spi.config.table.IngestionConfig;
+import org.apache.pinot.spi.config.table.SegmentPartitionConfig;
 import org.apache.pinot.spi.config.table.StarTreeIndexConfig;
 import org.apache.pinot.spi.config.table.TableConfig;
 import org.apache.pinot.spi.config.table.TableType;
@@ -543,6 +547,20 @@ public class TableConfigUtilsTest {
       // expected
     }
 
+    ColumnPartitionConfig columnPartitionConfig = new ColumnPartitionConfig("Murmur", 4);
+    Map<String, ColumnPartitionConfig> partitionConfigMap = new HashMap<>();
+    partitionConfigMap.put("myCol2", columnPartitionConfig);
+    SegmentPartitionConfig partitionConfig = new SegmentPartitionConfig(partitionConfigMap);
+    tableConfig =
+        new TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).setSegmentPartitionConfig(partitionConfig)
+            .build();
+    try {
+      TableConfigUtils.validate(tableConfig, schema);
+      Assert.fail("Should fail for invalid Segment Partition column name");
+    } catch (Exception e) {
+      // expected
+    }
+
     // Although this config makes no sense, it should pass the validation phase
     StarTreeIndexConfig starTreeIndexConfig = new StarTreeIndexConfig(Arrays.asList("myCol"),
         Arrays.asList("myCol"),


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org