You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2020/08/25 15:08:48 UTC
[hive] branch master updated: HIVE-23302: Create
HiveJdbcDatabaseAccessor for JDBC storage handler (Jesus Camacho Rodriguez,
reviewed by Krisztian Kasa)
This is an automated email from the ASF dual-hosted git repository.
jcamacho 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 f9668a2 HIVE-23302: Create HiveJdbcDatabaseAccessor for JDBC storage handler (Jesus Camacho Rodriguez, reviewed by Krisztian Kasa)
f9668a2 is described below
commit f9668a2e79269d25e7aecf9b5855cff001953d45
Author: Jesús Camacho Rodríguez <jc...@apache.org>
AuthorDate: Tue Aug 25 08:08:31 2020 -0700
HIVE-23302: Create HiveJdbcDatabaseAccessor for JDBC storage handler (Jesus Camacho Rodriguez, reviewed by Krisztian Kasa)
Closes apache/hive#1427
---
.../storage/jdbc/dao/DatabaseAccessorFactory.java | 4 ++
.../storage/jdbc/dao/HiveDatabaseAccessor.java | 44 ++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/DatabaseAccessorFactory.java b/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/DatabaseAccessorFactory.java
index f39a641..b37269a 100644
--- a/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/DatabaseAccessorFactory.java
+++ b/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/DatabaseAccessorFactory.java
@@ -55,6 +55,10 @@ public class DatabaseAccessorFactory {
accessor = new DB2DatabaseAccessor();
break;
+ case HIVE:
+ accessor = new HiveDatabaseAccessor();
+ break;
+
case DERBY:
accessor = new DerbyDatabaseAccessor();
break;
diff --git a/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/HiveDatabaseAccessor.java b/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/HiveDatabaseAccessor.java
new file mode 100644
index 0000000..8d70675
--- /dev/null
+++ b/jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/HiveDatabaseAccessor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.hive.storage.jdbc.dao;
+
+/**
+ * Hive specific data accessor.
+ */
+public class HiveDatabaseAccessor extends GenericJdbcDatabaseAccessor {
+
+ @Override
+ protected String addLimitAndOffsetToQuery(String sql, int limit, int offset) {
+ if (offset == 0) {
+ return addLimitToQuery(sql, limit);
+ } else {
+ if (limit == -1) {
+ return sql;
+ }
+ return sql + " LIMIT " + limit + " OFFSET " + offset;
+ }
+ }
+
+ @Override
+ protected String addLimitToQuery(String sql, int limit) {
+ if (limit == -1) {
+ return sql;
+ }
+ return sql + " LIMIT " + limit;
+ }
+}