You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ma...@apache.org on 2021/08/17 05:04:06 UTC

[hive] branch master updated: HIVE-25438 : Update partition column stats fails with invalid syntax error for MySql (Mahesh Kumar Behera, Ramesh Kumar Thangarajan)

This is an automated email from the ASF dual-hosted git repository.

mahesh 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 baf8247  HIVE-25438 : Update partition column stats fails with invalid syntax error for MySql (Mahesh Kumar Behera, Ramesh Kumar Thangarajan)
baf8247 is described below

commit baf8247af78f35a68fab0756f9d571c73cdf5f96
Author: mahesh kumar behera <ma...@apache.org>
AuthorDate: Tue Aug 17 10:33:54 2021 +0530

    HIVE-25438 : Update partition column stats fails with invalid syntax error for MySql (Mahesh Kumar Behera, Ramesh Kumar Thangarajan)
---
 .../apache/hadoop/hive/metastore/DirectSqlUpdateStat.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdateStat.java b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdateStat.java
index 6f1231d..2fb9d20 100644
--- a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdateStat.java
+++ b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DirectSqlUpdateStat.java
@@ -565,6 +565,14 @@ class DirectSqlUpdateStat {
     return partitionInfoMap;
   }
 
+  private void setAnsiQuotes(Connection dbConn) throws SQLException {
+    if (sqlGenerator.getDbProduct().isMYSQL()) {
+      try (Statement stmt = dbConn.createStatement()) {
+        stmt.execute("SET @@session.sql_mode=ANSI_QUOTES");
+      }
+    }
+  }
+
   /**
    * Update the statistics for the given partitions. Add the notification logs also.
    * @return map of partition key to column stats if successful, null otherwise.
@@ -582,6 +590,8 @@ class DirectSqlUpdateStat {
       jdoConn = pm.getDataStoreConnection();
       dbConn = (Connection) (jdoConn.getNativeConnection());
 
+      setAnsiQuotes(dbConn);
+
       Map<PartitionInfo, ColumnStatistics> partitionInfoMap = getPartitionInfo(dbConn, tbl.getId(), partColStatsMap);
 
       Map<String, Map<String, String>> result =
@@ -647,6 +657,8 @@ class DirectSqlUpdateStat {
       jdoConn = pm.getDataStoreConnection();
       dbConn = (Connection) (jdoConn.getNativeConnection());
 
+      setAnsiQuotes(dbConn);
+
       // This loop will be iterated at max twice. If there is no records, it will first insert and then do a select.
       // We are not using any upsert operations as select for update and then update is required to make sure that
       // the caller gets a reserved range for CSId not used by any other thread.