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

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

                Author: ASF GitHub Bot
            Created on: 01/Jun/21 19:14
            Start Date: 01/Jun/21 19:14
    Worklog Time Spent: 10m 
      Work Description: yongzhi commented on a change in pull request #2336:
URL: https://github.com/apache/hive/pull/2336#discussion_r643412805



##########
File path: 
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DefaultIncompatibleTableChangeHandler.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>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.InvalidOperationException;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Default incompatible table change handler. This is invoked by the {@link
+ * HiveAlterHandler} when a table is altered to check if the column type 
changes if any
+ * are allowed or not.
+ */
+public class DefaultIncompatibleTableChangeHandler implements
+    IMetaStoreIncompatibleChangeHandler {
+
+  private static final Logger LOG = LoggerFactory
+      .getLogger(DefaultIncompatibleTableChangeHandler.class);
+  private static final DefaultIncompatibleTableChangeHandler INSTANCE =
+      new DefaultIncompatibleTableChangeHandler();
+
+  private DefaultIncompatibleTableChangeHandler() {
+  }
+
+  public static DefaultIncompatibleTableChangeHandler get() {
+    return INSTANCE;
+  }
+
+  /**
+   * Checks if the column type changes in the oldTable and newTable are 
allowed or not. In
+   * addition to checking if the incompatible changes are allowed or not, this 
also checks
+   * if the table serde library belongs to a list of table serdes which 
support making any
+   * column type changes.
+   *
+   * @param conf     The configuration which if incompatible col type changes 
are allowed
+   *                 or not.
+   * @param oldTable The instance of the table being altered.
+   * @param newTable The new instance of the table which represents the 
altered state of
+   *                 the table.
+   * @throws InvalidOperationException
+   */
+  @Override
+  public void allowChange(Configuration conf, Table oldTable, Table newTable)
+      throws InvalidOperationException {
+    if (!MetastoreConf.getBoolVar(conf,
+        MetastoreConf.ConfVars.DISALLOW_INCOMPATIBLE_COL_TYPE_CHANGES)) {
+      // incompatible column changes are allowed for all
+      return;
+    }
+    if (oldTable.getTableType().equals(TableType.VIRTUAL_VIEW.toString())) {
+      // Views derive the column type from the base table definition. So the 
view
+      // definition can be altered to change the column types. The column type
+      // compatibility checks should be done only for non-views.
+      return;
+    }
+    checkColTypeChangeCompatible(conf, oldTable, newTable);
+  }
+
+  private void checkColTypeChangeCompatible(Configuration conf, Table oldTable,

Review comment:
       Should we remove the checkColTypeChangeCompatible in 
HiveAlterHandler.java ?




-- 
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 604713)
    Time Spent: 20m  (was: 10m)

> hive.metastore.disallow.incompatible.col.type.changes is too restrictive for 
> some storage formats
> -------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-24987
>                 URL: https://issues.apache.org/jira/browse/HIVE-24987
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Vihang Karajgaonkar
>            Assignee: Vihang Karajgaonkar
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Currently when {{hive.metastore.disallow.incompatible.col.type.changes}} is 
> set to true it disallows any schema changes which are deemed as backwards 
> incompatible e.g dropping a column of a table. While this may be a correct 
> thing to do for Parquet or Orc tables, it is too restrictive for storage 
> formats like Kudu. 
> Currently, for Kudu tables, Impala supports dropping a column. But if we set 
> this config to true metastore disallows changing the schema of the metastore 
> table. I am assuming this would be problematic for Iceberg tables too which 
> supports such schema changes.
> The proposal is to have a new configuration which provided a exclusion list 
> of the table fileformat where this check will be skipped. Currently, we will 
> only include Kudu tables to skip this check.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to