You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2020/07/18 20:58:58 UTC

[incubator-pinot] 01/01: Disallow table creation with dot in the table name

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

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

commit 6d0ae697191c5f9d68b8edf78d5bf0cdd2b58007
Author: Xiang Fu <fx...@gmail.com>
AuthorDate: Sat Jul 18 13:41:49 2020 -0700

    Disallow table creation with dot in the table name
---
 .../pinot/controller/api/PinotTableRestletResourceTest.java   | 11 +++++++++++
 .../java/org/apache/pinot/core/util/TableConfigUtils.java     |  9 +++++++++
 2 files changed, 20 insertions(+)

diff --git a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java
index 52ad0fa..d1cd559 100644
--- a/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java
+++ b/pinot-controller/src/test/java/org/apache/pinot/controller/api/PinotTableRestletResourceTest.java
@@ -96,6 +96,17 @@ public class PinotTableRestletResourceTest extends ControllerTest {
       Assert.assertTrue(e.getMessage().startsWith("Server returned HTTP response code: 400"));
     }
 
+    offlineTableConfig = _offlineBuilder.build();
+    offlineTableConfigJson = (ObjectNode) offlineTableConfig.toJsonNode();
+    offlineTableConfigJson.put(TableConfig.TABLE_NAME_KEY, "bad.table.with.dot");
+    try {
+      sendPostRequest(_createTableUrl, offlineTableConfigJson.toString());
+      Assert.fail("Creation of an OFFLINE table with dot in the table name does not fail");
+    } catch (IOException e) {
+      // Expected 400 Bad Request
+      Assert.assertTrue(e.getMessage().startsWith("Server returned HTTP response code: 400"));
+    }
+
     // Create an OFFLINE table with a valid name which should succeed
     offlineTableConfig = _offlineBuilder.setTableName("valid_table_name").build();
     String offlineTableConfigString = offlineTableConfig.toJsonString();
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 de74e8e..99efa2f 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
@@ -53,11 +53,20 @@ public final class TableConfigUtils {
    * </ul>
    */
   public static void validate(TableConfig tableConfig) {
+    validateGeneralConfig(tableConfig);
     validateFieldConfigList(tableConfig);
     validateValidationConfig(tableConfig);
     validateIngestionConfig(tableConfig.getIngestionConfig());
   }
 
+  private static void validateGeneralConfig(TableConfig tableConfig) {
+    String tableName = tableConfig.getTableName();
+    if (tableName.contains(".")) {
+      throw new IllegalStateException(
+          "Table name: '" + tableName + "' containing '.' is not allowed");
+    }
+  }
+
   private static void validateFieldConfigList(TableConfig tableConfig) {
     List<FieldConfig> fieldConfigList = tableConfig.getFieldConfigList();
     if (fieldConfigList != null) {


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