-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HIVE-27597: Implement data connector for Hive to Hive federation over… (
#4720) * HIVE-27597: Implement data connector for Hive to Hive federation over JDBC (Naveen Gangam)
- Loading branch information
Showing
11 changed files
with
124 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...n/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/HiveJDBCConnectorProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* 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.hadoop.hive.metastore.dataconnector.jdbc; | ||
|
||
import org.apache.hadoop.hive.metastore.ColumnType; | ||
import org.apache.hadoop.hive.metastore.api.DataConnector; | ||
import org.apache.hadoop.hive.metastore.api.MetaException; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
public class HiveJDBCConnectorProvider extends AbstractJDBCConnectorProvider { | ||
private static final Logger LOG = LoggerFactory.getLogger(HiveJDBCConnectorProvider.class); | ||
private static final String DRIVER_CLASS = "org.apache.hive.jdbc.HiveDriver"; | ||
// for Hive the type for connector is "HIVEJDBC" where as on the table we want it to be "HIVE" | ||
protected static final String mappedType = "HIVE"; | ||
|
||
public HiveJDBCConnectorProvider(String dbName, DataConnector dataConn) { | ||
super(dbName, dataConn, DRIVER_CLASS); | ||
} | ||
|
||
@Override protected String getCatalogName() { | ||
return null; | ||
} | ||
|
||
@Override protected String getDatabaseName() { | ||
return scoped_db; | ||
} | ||
|
||
@Override protected String getDataType(String dbDataType, int size) { | ||
String mappedType = super.getDataType(dbDataType, size); | ||
if (!mappedType.equalsIgnoreCase(ColumnType.VOID_TYPE_NAME)) { | ||
return mappedType; | ||
} | ||
|
||
// map any db specific types here. | ||
switch (dbDataType.trim().toLowerCase()) | ||
{ | ||
case "string": | ||
case "varchar": | ||
mappedType = ColumnType.STRING_TYPE_NAME; | ||
break; | ||
default: | ||
// TODO Hive has support for complex data types but JDBCSerDe only supports primitive types | ||
// SerDe needs to enhanced first to be able to support complex types over federation | ||
mappedType = ColumnType.VOID_TYPE_NAME; | ||
break; | ||
} | ||
return mappedType; | ||
} | ||
|
||
@Override protected String getDatasourceType() { return mappedType; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.