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

luoc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git


The following commit(s) were added to refs/heads/master by this push:
     new d504848  DRILL-8049: Make rule names for Iceberg plugin instances 
unique
d504848 is described below

commit d5048487180347db8f8d9b2eefd04ceec54d13d0
Author: Volodymyr Vysotskyi <[email protected]>
AuthorDate: Fri Nov 19 19:05:17 2021 +0200

    DRILL-8049: Make rule names for Iceberg plugin instances unique
---
 .../drill/exec/store/iceberg/format/IcebergFormatPlugin.java   | 10 +++++++++-
 .../apache/drill/exec/store/iceberg/IcebergQueriesTest.java    |  4 ++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/format/IcebergFormatPlugin.java
 
b/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/format/IcebergFormatPlugin.java
index 2f5de9c..00b7139 100644
--- 
a/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/format/IcebergFormatPlugin.java
+++ 
b/contrib/format-iceberg/src/main/java/org/apache/drill/exec/store/iceberg/format/IcebergFormatPlugin.java
@@ -46,11 +46,19 @@ import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class IcebergFormatPlugin implements FormatPlugin {
 
   private static final String ICEBERG_CONVENTION_PREFIX = "ICEBERG.";
 
+  /**
+   * Generator for format id values. Formats with the same name may be defined
+   * in multiple storage plugins, so using the unique id within the convention 
name
+   * to ensure the rule names will be unique for different plugin instances.
+   */
+  private static final AtomicInteger NEXT_ID = new AtomicInteger(0);
+
   private final FileSystemConfig storageConfig;
 
   private final IcebergFormatPluginConfig config;
@@ -77,7 +85,7 @@ public class IcebergFormatPlugin implements FormatPlugin {
     this.context = context;
     this.name = name;
     this.matcher = new IcebergFormatMatcher(this);
-    this.storagePluginRulesSupplier = storagePluginRulesSupplier(name);
+    this.storagePluginRulesSupplier = storagePluginRulesSupplier(name + 
NEXT_ID.getAndIncrement());
   }
 
   private static StoragePluginRulesSupplier storagePluginRulesSupplier(String 
name) {
diff --git 
a/contrib/format-iceberg/src/test/java/org/apache/drill/exec/store/iceberg/IcebergQueriesTest.java
 
b/contrib/format-iceberg/src/test/java/org/apache/drill/exec/store/iceberg/IcebergQueriesTest.java
index 8b7c600..1c97252 100644
--- 
a/contrib/format-iceberg/src/test/java/org/apache/drill/exec/store/iceberg/IcebergQueriesTest.java
+++ 
b/contrib/format-iceberg/src/test/java/org/apache/drill/exec/store/iceberg/IcebergQueriesTest.java
@@ -96,6 +96,10 @@ public class IcebergQueriesTest extends ClusterTest {
     newPluginConfig.setEnabled(pluginConfig.isEnabled());
     pluginRegistry.put(DFS_PLUGIN_NAME, newPluginConfig);
 
+    // defining another plugin with iceberg format to ensure that DRILL-8049 
is fixed
+    FileSystemConfig anotherFileSystemConfig = 
pluginConfig.copyWithFormats(formats);
+    pluginRegistry.put("dfs2", anotherFileSystemConfig);
+
     Configuration config = new Configuration();
     config.set(FileSystem.FS_DEFAULT_NAME_KEY, FileSystem.DEFAULT_FS);
 

Reply via email to