You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pv...@apache.org on 2019/11/25 10:49:42 UTC
[hive] branch master updated: HIVE-22506: Read-only transactions
feature flag (Denys Kuzmenko reviewed by Peter Vary)
This is an automated email from the ASF dual-hosted git repository.
pvary 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 da58a38 HIVE-22506: Read-only transactions feature flag (Denys Kuzmenko reviewed by Peter Vary)
da58a38 is described below
commit da58a382d6edab51b797af85beb148fac8e356aa
Author: denys kuzmenko <dk...@cloudera.com>
AuthorDate: Mon Nov 25 11:42:17 2019 +0100
HIVE-22506: Read-only transactions feature flag (Denys Kuzmenko reviewed by Peter Vary)
---
.../java/org/apache/hadoop/hive/conf/HiveConf.java | 4 ++++
ql/src/java/org/apache/hadoop/hive/ql/Driver.java | 2 +-
.../java/org/apache/hadoop/hive/ql/io/AcidUtils.java | 5 +++--
.../apache/hadoop/hive/ql/parse/TestParseUtils.java | 20 +++++++++++++++++---
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
index bf03fe6..cfc9091 100644
--- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
+++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
@@ -2647,6 +2647,10 @@ public class HiveConf extends Configuration {
"are not hidden by the INSERT OVERWRITE."),
HIVE_TXN_STATS_ENABLED("hive.txn.stats.enabled", true,
"Whether Hive supports transactional stats (accurate stats for transactional tables)"),
+
+ HIVE_TXN_READONLY_ENABLED("hive.txn.readonly.enabled", false,
+ "Enables read-only transaction classification and related optimizations"),
+
/**
* @deprecated Use MetastoreConf.TXN_TIMEOUT
*/
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
index bb41c15..54d12ba 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/Driver.java
@@ -425,7 +425,7 @@ public class Driver implements IDriver {
driverContext.getQueryState().getHiveOperation().equals(HiveOperation.REPLDUMP)) {
setLastReplIdForDump(driverContext.getQueryState().getConf());
}
- driverContext.setTxnType(AcidUtils.getTxnType(tree));
+ driverContext.setTxnType(AcidUtils.getTxnType(driverContext.getConf(), tree));
openTransaction(driverContext.getTxnType());
generateValidTxnList();
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
index 5b6f747..1824596 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java
@@ -2992,10 +2992,11 @@ public class AcidUtils {
* Determines transaction type based on query AST.
* @param tree AST
*/
- public static TxnType getTxnType(ASTNode tree) {
+ public static TxnType getTxnType(Configuration conf, ASTNode tree) {
final ASTSearcher astSearcher = new ASTSearcher();
- return (tree.getToken().getType() == HiveParser.TOK_QUERY &&
+ return (HiveConf.getBoolVar(conf, ConfVars.HIVE_TXN_READONLY_ENABLED) &&
+ tree.getToken().getType() == HiveParser.TOK_QUERY &&
Stream.of(
new int[]{HiveParser.TOK_INSERT_INTO},
new int[]{HiveParser.TOK_INSERT, HiveParser.TOK_TAB})
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseUtils.java b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseUtils.java
index bf8a028..e606713 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseUtils.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/parse/TestParseUtils.java
@@ -18,6 +18,8 @@
package org.apache.hadoop.hive.ql.parse;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.api.TxnType;
import org.apache.hadoop.hive.ql.io.AcidUtils;
@@ -38,10 +40,12 @@ public class TestParseUtils {
private String query;
private TxnType txnType;
+ private Configuration conf;
public TestParseUtils(String query, TxnType txnType) {
this.query = query;
this.txnType = txnType;
+ this.conf = new HiveConf();
}
@Parameters
@@ -89,8 +93,18 @@ public class TestParseUtils {
}
@Test
- public void testTxnType() throws ParseException {
- Assert.assertEquals(
- AcidUtils.getTxnType(ParseUtils.parse(query)), txnType);
+ public void testTxnTypeWithEnabledReadOnlyFeature() throws ParseException {
+ enableReadOnlyTxnFeature(true);
+ Assert.assertEquals(AcidUtils.getTxnType(conf, ParseUtils.parse(query)), txnType);
+ }
+
+ @Test
+ public void testTxnTypeWithDisabledReadOnlyFeature() throws ParseException {
+ enableReadOnlyTxnFeature(false);
+ Assert.assertEquals(AcidUtils.getTxnType(conf, ParseUtils.parse(query)), TxnType.DEFAULT);
+ }
+
+ private void enableReadOnlyTxnFeature(boolean featureFlag) {
+ conf.setBoolean(HiveConf.ConfVars.HIVE_TXN_READONLY_ENABLED.varname, featureFlag);
}
}