This is an automated email from the ASF dual-hosted git repository.
kharekartik 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 bb83f5c7e2 Add capability to update and delete table config via CLI
(#9852)
bb83f5c7e2 is described below
commit bb83f5c7e2bd12d4d028bbf12df19cd34742cad5
Author: Kartik Khare <[email protected]>
AuthorDate: Wed Dec 7 15:03:40 2022 +0530
Add capability to update and delete table config via CLI (#9852)
* Add capability top update and delete table config via CLI
* Add old command for backward compatibility
* Only use update command
* revert linting
Co-authored-by: Kartik Khare <[email protected]>
---
.../pinot/tools/admin/command/AddTableCommand.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddTableCommand.java
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddTableCommand.java
index 707b329c65..a9950cdf4f 100644
---
a/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddTableCommand.java
+++
b/pinot-tools/src/main/java/org/apache/pinot/tools/admin/command/AddTableCommand.java
@@ -75,6 +75,10 @@ public class AddTableCommand extends
AbstractBaseAdminCommand implements Command
@CommandLine.Option(names = {"-controllerProtocol"}, required = false,
description = "protocol for controller.")
private String _controllerProtocol = CommonConstants.HTTP_PROTOCOL;
+ @CommandLine.Option(names = {"-update"}, required = false,
+ description = "Update the existing table instead of creating new one")
+ private boolean _update = false;
+
@CommandLine.Option(names = {"-exec"}, required = false, description =
"Execute the command.")
private boolean _exec;
@@ -191,6 +195,15 @@ public class AddTableCommand extends
AbstractBaseAdminCommand implements Command
return res.contains("successfully added");
}
+ public boolean sendTableUpdateRequest(JsonNode node, String tableName)
+ throws IOException {
+ String res = AbstractBaseAdminCommand.sendRequest("PUT",
+
ControllerRequestURLBuilder.baseUrl(_controllerAddress).forTableConfigsUpdate(tableName),
node.toString(),
+ makeAuthHeaders(makeAuthProvider(_authProvider, _authTokenUrl,
_authToken, _user, _password)));
+ LOGGER.info(res);
+ return res.contains("TableConfigs updated");
+ }
+
@Override
public boolean execute()
throws Exception {
@@ -239,7 +252,11 @@ public class AddTableCommand extends
AbstractBaseAdminCommand implements Command
"Failed reading schema " + _schemaFile);
TableConfigs tableConfigs = new TableConfigs(rawTableName, schema,
offlineTableConfig, realtimeTableConfig);
- return sendTableCreationRequest(JsonUtils.objectToJsonNode(tableConfigs));
+ if (_update) {
+ return sendTableUpdateRequest(tableConfigs.toJsonNode(), rawTableName);
+ } else {
+ return sendTableCreationRequest(tableConfigs.toJsonNode());
+ }
}
private static <T> T attempt(Callable<T> callable, String errorMessage) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]