You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/06/02 09:53:00 UTC

[jira] [Work logged] (HIVE-26228) Implement Iceberg table rollback feature

     [ https://issues.apache.org/jira/browse/HIVE-26228?focusedWorklogId=777380&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-777380 ]

ASF GitHub Bot logged work on HIVE-26228:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Jun/22 09:52
            Start Date: 02/Jun/22 09:52
    Worklog Time Spent: 10m 
      Work Description: szlta commented on code in PR #3287:
URL: https://github.com/apache/hive/pull/3287#discussion_r887684398


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AbstractBaseAlterTableAnalyzer.java:
##########
@@ -161,7 +161,8 @@ protected void validateAlterTableType(Table table, AlterTableType op, boolean ex
     }
     if (table.isNonNative() && table.getStorageHandler() != null) {
       if (!table.getStorageHandler().isAllowedAlterOperation(op) ||

Review Comment:
   I may be missing the context here, but could you remind me why we don't incorporate these operation type checks within isAllowedAlterOperation() method of the storagehandler? (Meaning both setpartition and execute)



##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/execute/AlterTableExecuteAnalyzer.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.ddl.table.execute;
+
+import org.apache.hadoop.hive.common.TableName;
+import org.apache.hadoop.hive.common.type.TimestampTZ;
+import org.apache.hadoop.hive.common.type.TimestampTZUtil;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.ql.QueryState;
+import org.apache.hadoop.hive.ql.ddl.DDLSemanticAnalyzerFactory.DDLType;
+import org.apache.hadoop.hive.ql.ddl.DDLWork;
+import org.apache.hadoop.hive.ql.ddl.table.AbstractAlterTableAnalyzer;
+import org.apache.hadoop.hive.ql.ddl.table.AlterTableType;
+import org.apache.hadoop.hive.ql.exec.TaskFactory;
+import org.apache.hadoop.hive.ql.hooks.ReadEntity;
+import org.apache.hadoop.hive.ql.metadata.Table;
+import org.apache.hadoop.hive.ql.parse.ASTNode;
+import org.apache.hadoop.hive.ql.parse.HiveParser;
+import org.apache.hadoop.hive.ql.parse.AlterTableExecuteSpec;
+import org.apache.hadoop.hive.ql.parse.SemanticException;
+import org.apache.hadoop.hive.ql.plan.PlanUtils;
+import org.apache.hadoop.hive.ql.session.SessionState;
+
+import java.time.ZoneId;
+import java.util.Map;
+
+import static org.apache.hadoop.hive.ql.parse.AlterTableExecuteSpec.ExecuteOperationType.ROLLBACK;
+import static org.apache.hadoop.hive.ql.parse.AlterTableExecuteSpec.RollbackSpec.RollbackType.TIME;
+import static org.apache.hadoop.hive.ql.parse.AlterTableExecuteSpec.RollbackSpec.RollbackType.VERSION;
+
+/**
+ * Analyzer for ALTER TABLE ... EXECUTE commands.
+ */
+@DDLType(types = HiveParser.TOK_ALTERTABLE_EXECUTE)
+public class AlterTableExecuteAnalyzer extends AbstractAlterTableAnalyzer {
+
+  public AlterTableExecuteAnalyzer(QueryState queryState) throws SemanticException {
+    super(queryState);
+  }
+
+  @Override
+  protected void analyzeCommand(TableName tableName, Map<String, String> partitionSpec, ASTNode command)
+      throws SemanticException {
+    Table table = getTable(tableName);
+    // the first child must be the execute operation type
+    ASTNode executeCommandType = (ASTNode) command.getChild(0);
+    validateAlterTableType(table, AlterTableType.EXECUTE, false);
+    inputs.add(new ReadEntity(table));
+    AlterTableExecuteDesc desc = null;
+    if (HiveParser.KW_ROLLBACK == executeCommandType.getType()) {
+      AlterTableExecuteSpec<AlterTableExecuteSpec.RollbackSpec> spec;
+      // the second child must be the rollback parameter
+      ASTNode child = (ASTNode) command.getChild(1);
+
+      if (child.getType() == HiveParser.StringLiteral) {

Review Comment:
   What happens if the user specifies a timezone in this literal?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 777380)
    Time Spent: 4.5h  (was: 4h 20m)

> Implement Iceberg table rollback feature
> ----------------------------------------
>
>                 Key: HIVE-26228
>                 URL: https://issues.apache.org/jira/browse/HIVE-26228
>             Project: Hive
>          Issue Type: New Feature
>            Reporter: László Pintér
>            Assignee: László Pintér
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> We should allow rolling back iceberg table's data to the state at an older table snapshot. 
> Rollback to the last snapshot before a specific timestamp
> {code:java}
> ALTER TABLE ice_t EXECUTE ROLLBACK('2022-05-12 00:00:00')
> {code}
> Rollback to a specific snapshot ID
> {code:java}
>  ALTER TABLE ice_t EXECUTE ROLLBACK(1111); 
> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)