You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ku...@apache.org on 2019/07/25 08:42:12 UTC
[hive] branch master updated: HIVE-21957: Create temporary table
like should omit transactional properties (Laszlo Pinter via Marta Kuczora)
This is an automated email from the ASF dual-hosted git repository.
kuczoram pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new cc01599 HIVE-21957: Create temporary table like should omit transactional properties (Laszlo Pinter via Marta Kuczora)
cc01599 is described below
commit cc015995bb21ec04c876f6fe9a0064dd56ba5bed
Author: Laszlo Pinter <lp...@cloudera.com>
AuthorDate: Thu Jul 25 10:41:40 2019 +0200
HIVE-21957: Create temporary table like should omit transactional properties (Laszlo Pinter via Marta Kuczora)
---
.../hadoop/hive/ql/parse/SemanticAnalyzer.java | 33 +++++++++-------------
1 file changed, 14 insertions(+), 19 deletions(-)
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
index 91106b6..8ff00fb 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
@@ -13358,13 +13358,14 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
* defined in {@link SemanticAnalyzer#UPDATED_TBL_PROPS}.
* @param source properties of source table, must be not null.
* @param target properties of target table.
+ * @param skipped a list of properties which should be not overwritten. It can be null or empty.
*/
- private void updateDefaultTblProps(Map<String, String> source, Map<String, String> target) {
+ private void updateDefaultTblProps(Map<String, String> source, Map<String, String> target, List<String> skipped) {
if (source == null || target == null) {
return;
}
for (String property : UPDATED_TBL_PROPS) {
- if (source.containsKey(property)) {
+ if ((skipped == null || !skipped.contains(property)) && source.containsKey(property)) {
target.put(property, source.get(property));
}
}
@@ -13579,16 +13580,6 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
if (child.getChildCount() > 0) {
likeTableName = getUnescapedName((ASTNode) child.getChild(0));
if (likeTableName != null) {
- Table likeTable = getTable(likeTableName, false);
- if (likeTable != null) {
- Map<String, String> likeTableProps = likeTable.getParameters();
- if (likeTableProps.containsKey(hive_metastoreConstants.TABLE_IS_TRANSACTIONAL)) {
- isTransactional = true;
- }
- if (likeTable.isTemporary()) {
- isTemporary = true;
- }
- }
if (command_type == CTAS) {
throw new SemanticException(ErrorMsg.CTAS_CTLT_COEXISTENCE
.getMsg());
@@ -13810,14 +13801,18 @@ public class SemanticAnalyzer extends BaseSemanticAnalyzer {
addDbAndTabToOutputs(qualifiedTabName, TableType.MANAGED_TABLE, isTemporary, tblProps);
Table likeTable = getTable(likeTableName, false);
- if (isTemporary) {
- if (likeTable != null && likeTable.getPartCols().size() > 0) {
- throw new SemanticException("Partition columns are not supported on temporary tables "
- + "and source table in CREATE TABLE LIKE is partitioned.");
- }
- }
if (likeTable != null) {
- updateDefaultTblProps(likeTable.getParameters(), tblProps);
+ if (isTemporary) {
+ if (likeTable.getPartCols().size() > 0) {
+ throw new SemanticException("Partition columns are not supported on temporary tables "
+ + "and source table in CREATE TABLE LIKE is partitioned.");
+ }
+ updateDefaultTblProps(likeTable.getParameters(), tblProps,
+ new ArrayList<>(Arrays.asList(hive_metastoreConstants.TABLE_IS_TRANSACTIONAL,
+ hive_metastoreConstants.TABLE_TRANSACTIONAL_PROPERTIES)));
+ } else {
+ updateDefaultTblProps(likeTable.getParameters(), tblProps, null);
+ }
}
CreateTableLikeDesc crtTblLikeDesc = new CreateTableLikeDesc(dbDotTab, isExt, isTemporary,
storageFormat.getInputFormat(), storageFormat.getOutputFormat(), location,