Fix Hive & DB2 (#4147)

This commit is contained in:
Mayur Singal 2022-04-14 22:57:05 +05:30 committed by GitHub
parent 2e04204af9
commit c48bc18065
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 29 deletions

View File

@ -1,10 +1,10 @@
{ {
"$id": "https://open-metadata.org/schema/entity/services/connections/database/db2Connection.json", "$id": "https://open-metadata.org/schema/entity/services/connections/database/db2Connection.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "DB2Connection", "title": "Db2Connection",
"description": "DB2 Connection Config", "description": "Db2 Connection Config",
"type": "object", "type": "object",
"javaType": "org.openmetadata.catalog.services.connections.database.DB2Connection", "javaType": "org.openmetadata.catalog.services.connections.database.Db2Connection",
"definitions": { "definitions": {
"db2Type": { "db2Type": {
"description": "Service type.", "description": "Service type.",

View File

@ -1,10 +1,10 @@
{ {
"$id": "https://open-metadata.org/schema/entity/services/connections/database/hiveSQLConnection.json", "$id": "https://open-metadata.org/schema/entity/services/connections/database/hiveConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "HiveSQLConnection", "title": "HiveConnection",
"description": "Hive SQL Connection Config", "description": "Hive SQL Connection Config",
"type": "object", "type": "object",
"javaType": "org.openmetadata.catalog.services.connections.database.HiveSQLConnection", "javaType": "org.openmetadata.catalog.services.connections.database.HiveConnection",
"definitions": { "definitions": {
"hiveType": { "hiveType": {
"description": "Service type.", "description": "Service type.",

View File

@ -29,7 +29,7 @@ def get_pk_constraint(self, bind, table_name, schema=None, **kw):
DB2Dialect.get_pk_constraint = get_pk_constraint DB2Dialect.get_pk_constraint = get_pk_constraint
from metadata.generated.schema.entity.services.connections.database.db2Connection import ( from metadata.generated.schema.entity.services.connections.database.db2Connection import (
DB2Connection, Db2Connection,
) )
@ -40,9 +40,9 @@ class Db2Source(SQLSource):
@classmethod @classmethod
def create(cls, config_dict, metadata_config: OpenMetadataConnection): def create(cls, config_dict, metadata_config: OpenMetadataConnection):
config: WorkflowSource = WorkflowSource.parse_obj(config_dict) config: WorkflowSource = WorkflowSource.parse_obj(config_dict)
connection: DB2Connection = config.serviceConnection.__root__.config connection: Db2Connection = config.serviceConnection.__root__.config
if not isinstance(connection, DB2Connection): if not isinstance(connection, Db2Connection):
raise InvalidSourceException( raise InvalidSourceException(
f"Expected DB2Connection, but got {connection}" f"Expected Db2Connection, but got {connection}"
) )
return cls(config, metadata_config) return cls(config, metadata_config)

View File

@ -74,7 +74,7 @@ HiveDialect.get_table_names = get_table_names
from metadata.generated.schema.entity.services.connections.database.hiveConnection import ( from metadata.generated.schema.entity.services.connections.database.hiveConnection import (
HiveSQLConnection, HiveConnection,
) )
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import ( from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
OpenMetadataConnection, OpenMetadataConnection,
@ -92,10 +92,10 @@ class HiveSource(SQLSource):
@classmethod @classmethod
def create(cls, config_dict, metadata_config: OpenMetadataConnection): def create(cls, config_dict, metadata_config: OpenMetadataConnection):
config: HiveSQLConnection = WorkflowSource.parse_obj(config_dict) config: HiveConnection = WorkflowSource.parse_obj(config_dict)
connection: HiveSQLConnection = config.serviceConnection.__root__.config connection: HiveConnection = config.serviceConnection.__root__.config
if not isinstance(connection, HiveSQLConnection): if not isinstance(connection, HiveConnection):
raise InvalidSourceException( raise InvalidSourceException(
f"Expected HiveSQLConnection, but got {connection}" f"Expected HiveConnection, but got {connection}"
) )
return cls(config, metadata_config) return cls(config, metadata_config)

View File

@ -29,10 +29,10 @@ from metadata.generated.schema.entity.services.connections.database.databricksCo
DatabricksConnection, DatabricksConnection,
) )
from metadata.generated.schema.entity.services.connections.database.db2Connection import ( from metadata.generated.schema.entity.services.connections.database.db2Connection import (
DB2Connection, Db2Connection,
) )
from metadata.generated.schema.entity.services.connections.database.hiveConnection import ( from metadata.generated.schema.entity.services.connections.database.hiveConnection import (
HiveSQLConnection, HiveConnection,
) )
from metadata.generated.schema.entity.services.connections.database.mariaDBConnection import ( from metadata.generated.schema.entity.services.connections.database.mariaDBConnection import (
MariaDBConnection, MariaDBConnection,
@ -116,7 +116,7 @@ def get_connection_url(connection):
@get_connection_url.register(ClickhouseConnection) @get_connection_url.register(ClickhouseConnection)
@get_connection_url.register(SingleStoreConnection) @get_connection_url.register(SingleStoreConnection)
@get_connection_url.register(VerticaConnection) @get_connection_url.register(VerticaConnection)
@get_connection_url.register(DB2Connection) @get_connection_url.register(Db2Connection)
def _(connection): def _(connection):
return get_connection_url_common(connection) return get_connection_url_common(connection)
@ -245,7 +245,7 @@ def _(connection: SnowflakeConnection):
@get_connection_url.register @get_connection_url.register
def _(connection: HiveSQLConnection): def _(connection: HiveConnection):
url = get_connection_url_common(connection) url = get_connection_url_common(connection)
if connection.authOptions: if connection.authOptions:
return f"{url};{connection.authOptions}" return f"{url};{connection.authOptions}"

View File

@ -17,8 +17,8 @@ from metadata.generated.schema.entity.services.connections.database.databricksCo
DatabricksScheme, DatabricksScheme,
) )
from metadata.generated.schema.entity.services.connections.database.hiveConnection import ( from metadata.generated.schema.entity.services.connections.database.hiveConnection import (
HiveConnection,
HiveScheme, HiveScheme,
HiveSQLConnection,
) )
from metadata.generated.schema.entity.services.connections.database.trinoConnection import ( from metadata.generated.schema.entity.services.connections.database.trinoConnection import (
TrinoConnection, TrinoConnection,
@ -53,14 +53,14 @@ class SouceConnectionTest(TestCase):
def test_hive_url(self): def test_hive_url(self):
expected_result = "hive://localhost:10000/default" expected_result = "hive://localhost:10000/default"
databricks_conn_obj = HiveSQLConnection( databricks_conn_obj = HiveConnection(
scheme=HiveScheme.hive, hostPort="localhost:10000", database="default" scheme=HiveScheme.hive, hostPort="localhost:10000", database="default"
) )
assert expected_result == get_connection_url(databricks_conn_obj) assert expected_result == get_connection_url(databricks_conn_obj)
def test_hive_url_auth(self): def test_hive_url_auth(self):
expected_result = "hive://localhost:10000/default;auth=CUSTOM" expected_result = "hive://localhost:10000/default;auth=CUSTOM"
databricks_conn_obj = HiveSQLConnection( databricks_conn_obj = HiveConnection(
scheme=HiveScheme.hive, scheme=HiveScheme.hive,
hostPort="localhost:10000", hostPort="localhost:10000",
database="default", database="default",

View File

@ -1,10 +1,10 @@
{ {
"$id": "https://open-metadata.org/schema/entity/services/connections/database/db2Connection.json", "$id": "https://open-metadata.org/schema/entity/services/connections/database/db2Connection.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "DB2Connection", "title": "Db2Connection",
"description": "DB2 Connection Config", "description": "Db2 Connection Config",
"type": "object", "type": "object",
"javaType": "org.openmetadata.catalog.services.connections.database.DB2Connection", "javaType": "org.openmetadata.catalog.services.connections.database.Db2Connection",
"definitions": { "definitions": {
"db2Type": { "db2Type": {
"description": "Service type.", "description": "Service type.",

View File

@ -1,10 +1,10 @@
{ {
"$id": "https://open-metadata.org/schema/entity/services/connections/database/hiveSQLConnection.json", "$id": "https://open-metadata.org/schema/entity/services/connections/database/hiveConnection.json",
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"title": "HiveSQLConnection", "title": "HiveConnection",
"description": "Hive SQL Connection Config", "description": "Hive Connection Config",
"type": "object", "type": "object",
"javaType": "org.openmetadata.catalog.services.connections.database.HiveSQLConnection", "javaType": "org.openmetadata.catalog.services.connections.database.HiveConnection",
"definitions": { "definitions": {
"hiveType": { "hiveType": {
"description": "Service type.", "description": "Service type.",