jfsii commented on code in PR #4820:
URL: https://github.com/apache/hive/pull/4820#discussion_r1370641965


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/dump/events/AlterPartitionsHandler.java:
##########
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.ql.parse.repl.dump.events;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.Warehouse;
+import org.apache.hadoop.hive.metastore.api.NotificationEvent;
+import org.apache.hadoop.hive.metastore.messaging.AlterPartitionsMessage;
+import org.apache.hadoop.hive.ql.metadata.Partition;
+import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.parse.EximUtil;
+import org.apache.hadoop.hive.ql.parse.repl.DumpType;
+import org.apache.hadoop.hive.ql.parse.repl.dump.Utils;
+import org.apache.hadoop.hive.ql.parse.repl.load.DumpMetaData;
+
+public class AlterPartitionsHandler extends 
AbstractEventHandler<AlterPartitionsMessage> {
+  private final TableName tableName;
+  private final List<List<String>> part_vals;
+  // the isTruncateOp is always false now
+  private final boolean isTruncateOp;

Review Comment:
   Is there a follow up JIRA for this? I would just remove this until it is 
implemented.



##########
ql/src/java/org/apache/hadoop/hive/ql/parse/repl/load/message/TableHandler.java:
##########
@@ -113,9 +114,16 @@ private Tuple extract(Context context) throws 
SemanticException {
         writeId = alterTableMessage.getWriteId();
         break;
       case EVENT_ALTER_PARTITION:
-        AlterPartitionMessage msg = 
deserializer.getAlterPartitionMessage(context.dmd.getPayload());
-        tableType = msg.getTableObj().getTableType();
-        writeId = msg.getWriteId();
+        try {
+          AlterPartitionMessage msg = 
deserializer.getAlterPartitionMessage(context.dmd.getPayload());
+          tableType = msg.getTableObj().getTableType();
+          writeId = msg.getWriteId();
+        } catch (Exception e) {

Review Comment:
   Is there a better way to detect this? This looks like control flow via 
exceptions which is typically inefficient and sometimes confusing.



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionsMessage.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.messaging;
+
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+
+public abstract class AlterPartitionsMessage extends EventMessage {
+
+  protected AlterPartitionsMessage() {
+    super(EventType.ALTER_PARTITIONS);
+  }
+
+  public abstract String getTable();
+
+  public abstract String getTableType();
+
+  public abstract boolean getIsTruncateOp();
+
+  public abstract Long getWriteId();
+
+  public abstract List<String> getPartitionKeys();
+
+  public abstract List<List<String>> getPartitionValues();
+
+  public abstract List<Partition> getPartitionsAfter();
+
+  @Override
+  public EventMessage checkValid() {
+    if (getTable() == null) {
+      throw new IllegalStateException("Table name unset.");
+    }
+    if (getPartitionKeys() == null || getPartitionKeys().isEmpty()) {
+      throw new IllegalStateException("Partition keys unset");
+    }
+    if (getPartitionValues() == null || getPartitionValues().isEmpty()) {
+      new IllegalStateException("Partition values unset.");

Review Comment:
   I think you missed throw



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionsMessage.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.messaging;
+
+import java.util.List;
+
+import org.apache.hadoop.hive.metastore.api.Partition;
+
+public abstract class AlterPartitionsMessage extends EventMessage {
+
+  protected AlterPartitionsMessage() {
+    super(EventType.ALTER_PARTITIONS);
+  }
+
+  public abstract String getTable();
+
+  public abstract String getTableType();
+
+  public abstract boolean getIsTruncateOp();
+
+  public abstract Long getWriteId();
+
+  public abstract List<String> getPartitionKeys();
+
+  public abstract List<List<String>> getPartitionValues();
+
+  public abstract List<Partition> getPartitionsAfter();
+
+  @Override
+  public EventMessage checkValid() {
+    if (getTable() == null) {
+      throw new IllegalStateException("Table name unset.");
+    }
+    if (getPartitionKeys() == null || getPartitionKeys().isEmpty()) {
+      throw new IllegalStateException("Partition keys unset");
+    }
+    if (getPartitionValues() == null || getPartitionValues().isEmpty()) {
+      new IllegalStateException("Partition values unset.");
+    }
+
+    getPartitionsAfter().forEach(partition -> {
+      if (getWriteId() != partition.getWriteId()) {
+        new IllegalStateException("Different write id in the same event");

Review Comment:
   throw



##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/events/TestAlterPartitionsEvent.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>

Review Comment:
   remove the <p> and the one below (I think they are unneeded)



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to