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

xiangfu 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 a8b5fe77fa Allow override/force options when add schema (#11572)
a8b5fe77fa is described below

commit a8b5fe77fa0b22a4e94d52933059bfae92f05e97
Author: Xiang Fu <[email protected]>
AuthorDate: Wed Sep 13 20:08:02 2023 -0700

    Allow override/force options when add schema (#11572)
---
 .../tools/admin/command/AddSchemaCommand.java      | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git 
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddSchemaCommand.java
 
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddSchemaCommand.java
index 18d1dfd6c4..7ddc21b88d 100644
--- 
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddSchemaCommand.java
+++ 
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddSchemaCommand.java
@@ -20,6 +20,7 @@ package org.apache.pinot.tools.admin.command;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.net.URI;
 import java.util.Collections;
 import org.apache.pinot.common.utils.FileUploadDownloadClient;
 import org.apache.pinot.spi.auth.AuthProvider;
@@ -48,6 +49,14 @@ public class AddSchemaCommand extends 
AbstractBaseAdminCommand implements Comman
   @CommandLine.Option(names = {"-schemaFile"}, required = true, description = 
"Path to schema file.")
   private String _schemaFile = null;
 
+  @CommandLine.Option(names = {"-override"}, required = false, description = 
"Whether to override the schema if the "
+      + "schema exists.")
+  private boolean _override = false;
+
+  @CommandLine.Option(names = {"-force"}, required = false, description = 
"Whether to force overriding the schema if "
+      + "the schema exists.")
+  private boolean _force = false;
+
   @CommandLine.Option(names = {"-exec"}, required = false, description = 
"Execute the command.")
   private boolean _exec;
 
@@ -87,8 +96,8 @@ public class AddSchemaCommand extends 
AbstractBaseAdminCommand implements Comman
   @Override
   public String toString() {
     String retString = ("AddSchema -controllerProtocol " + _controllerProtocol 
+ " -controllerHost " + _controllerHost
-        + " -controllerPort " + _controllerPort + " -schemaFile " + 
_schemaFile + " -user " + _user + " -password "
-        + "[hidden]");
+        + " -controllerPort " + _controllerPort + " -schemaFile " + 
_schemaFile + " -override " + _override + " _force "
+        + _force + " -user " + _user + " -password " + "[hidden]");
 
     return ((_exec) ? (retString + " -exec") : retString);
   }
@@ -117,6 +126,16 @@ public class AddSchemaCommand extends 
AbstractBaseAdminCommand implements Comman
     return this;
   }
 
+  public AddSchemaCommand setOverride(boolean override) {
+    _override = override;
+    return this;
+  }
+
+  public AddSchemaCommand setForce(boolean force) {
+    _force = force;
+    return this;
+  }
+
   public void setUser(String user) {
     _user = user;
   }
@@ -155,8 +174,10 @@ public class AddSchemaCommand extends 
AbstractBaseAdminCommand implements Comman
 
     Schema schema = Schema.fromFile(schemaFile);
     try (FileUploadDownloadClient fileUploadDownloadClient = new 
FileUploadDownloadClient()) {
-      fileUploadDownloadClient.addSchema(FileUploadDownloadClient
-              .getUploadSchemaURI(_controllerProtocol, _controllerHost, 
Integer.parseInt(_controllerPort)),
+      URI schemaURI = FileUploadDownloadClient
+          .getUploadSchemaURI(_controllerProtocol, _controllerHost, 
Integer.parseInt(_controllerPort));
+      schemaURI = new URI(schemaURI + "?override=" + _override + "?force=" + 
_force);
+      fileUploadDownloadClient.addSchema(schemaURI,
           schema.getSchemaName(), schemaFile, 
makeAuthHeaders(makeAuthProvider(_authProvider, _authTokenUrl, _authToken,
               _user, _password)), Collections.emptyList());
     } catch (Exception e) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to