You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2019/12/13 22:09:36 UTC

[GitHub] [incubator-pinot] haibow commented on a change in pull request #4838: Update schema API to reload table on schema change when applicable

haibow commented on a change in pull request #4838: Update schema API to reload table on schema change when applicable
URL: https://github.com/apache/incubator-pinot/pull/4838#discussion_r357852526
 
 

 ##########
 File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
 ##########
 @@ -940,12 +941,55 @@ public PinotResourceManagerResponse deleteBrokerTenantFor(String tenantName) {
   /**
    * Schema APIs
    */
-  public void addOrUpdateSchema(Schema schema) {
+  public void addSchema(Schema schema, boolean shouldOverride) {
+    ZNRecord record = SchemaUtils.toZNRecord(schema);
+    String schemaName = schema.getSchemaName();
+    Schema oldSchema = ZKMetadataProvider.getSchema(_propertyStore, schemaName);
+
+    if (oldSchema != null && !shouldOverride) {
+      throw new RuntimeException("Schema exists. Not overriding it as requested.");
+    }
+
+    if (schema.equals(oldSchema)) {
+      LOGGER.info("New schema is the same with the existing schema. Not updating.");
+      return;
+    }
+
+    PinotHelixPropertyStoreZnRecordProvider propertyStoreHelper =
+        PinotHelixPropertyStoreZnRecordProvider.forSchema(_propertyStore);
+    propertyStoreHelper.set(schemaName, record);
+  }
+
+  public void updateSchema(Schema schema, boolean shouldAutoReload)
+      throws TableNotFoundException {
     ZNRecord record = SchemaUtils.toZNRecord(schema);
-    String name = schema.getSchemaName();
+    String schemaName = schema.getSchemaName();
+    Schema oldSchema = ZKMetadataProvider.getSchema(_propertyStore, schemaName);
+
+    if (oldSchema == null) {
+      throw new RuntimeException("Schema did not exist.");
 
 Review comment:
   Created a SchemaNotFoundException

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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