Fix#9251: DB2 connection config and ingestion update (#9322)

* DB2 connection config and ingestion update

* Update ingestion/src/metadata/ingestion/source/database/common_db_source.py

Co-authored-by: Ayush Shah <ayush@getcollate.io>

* Update ingestion/src/metadata/ingestion/source/database/common_db_source.py

Co-authored-by: Ayush Shah <ayush@getcollate.io>

* Update bootstrap/sql/com.mysql.cj.jdbc.Driver/v007__create_db_connection_info.sql

Co-authored-by: Ayush Shah <ayush@getcollate.io>
This commit is contained in:
Nahuel 2022-12-16 07:43:18 +01:00 committed by GitHub
parent a633befe2a
commit 819001182f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 43 additions and 23 deletions

View File

@ -36,3 +36,10 @@ CREATE TABLE IF NOT EXISTS alert_action_def (
PRIMARY KEY (id),
UNIQUE (name)
);
UPDATE dbservice_entity
SET json = JSON_INSERT(
JSON_REMOVE(json, '$.connection.config.databaseSchema'),
'$.connection.config.database',
JSON_EXTRACT(json, '$.connection.config.databaseSchema')
) where serviceType in ('Db2');

View File

@ -29,4 +29,13 @@ CREATE TABLE IF NOT EXISTS alert_action_def (
json JSONB NOT NULL,
PRIMARY KEY (id),
UNIQUE (name)
);
);
UPDATE dbservice_entity
SET json = jsonb_set(json, '{connection,config,database}', json#>'{connection,config,databaseSchema}')
where serviceType in ('Db2')
and json#>'{connection,config,databaseSchema}' is not null;
UPDATE dbservice_entity
SET json = json::jsonb #- '{connection,config,databaseSchema}'
where serviceType in ('Db2');

View File

@ -150,7 +150,7 @@ plugins: Dict[str, Set[str]] = {
"okta": {"okta~=2.3.0"},
"mlflow": {"mlflow-skinny~=1.26.1"},
"sklearn": {"scikit-learn==1.0.2"},
"db2": {"ibm-db-sa==0.3.7"},
"db2": {"ibm-db-sa==0.3.8"},
"clickhouse": {"clickhouse-driver==0.2.5", "clickhouse-sqlalchemy==0.2.3"},
"databricks": {"sqlalchemy-databricks==0.1.0"},
"singlestore": {"pymysql>=1.0.2"},

View File

@ -175,7 +175,11 @@ class CommonDbSourceService(
f"Table description error for table [{schema_name}.{table_name}]: {exc}"
)
else:
description = table_info["text"]
if hasattr(table_info, "text"):
description = table_info["text"]
# DB2 connector does not return a str type
if isinstance(description, list):
description = description[0]
return description
def get_tables_name_and_type(self) -> Optional[Iterable[Tuple[str, str]]]:

View File

@ -47,5 +47,6 @@ def _(*_, **__):
@compiles(ConnTestFn, Dialects.Db2)
@compiles(ConnTestFn, Dialects.IbmDbSa)
def _(*_, **__):
return "SELECT 42 FROM SYSIBM.SYSDUMMY1;"

View File

@ -60,6 +60,7 @@ class Dialects(Enum):
AzureSQL = "azuresql"
SingleStore = "singlestore"
SQLite = "sqlite"
IbmDbSa = "ibm_db_sa"
# Sometimes we want to skip certain types for computing metrics.

View File

@ -512,21 +512,13 @@ class SouceConnectionTest(TestCase):
assert expected_url == get_connection_url(singleStore_conn_obj)
def test_db2_url(self):
# connection arguments without db
expected_url = "db2+ibm_db://openmetadata_user:@localhost:50000"
db2_conn_obj = Db2Connection(
scheme=Db2Scheme.db2_ibm_db,
username="openmetadata_user",
hostPort="localhost:50000",
)
assert expected_url == get_connection_url(db2_conn_obj)
# connection arguments with db
expected_url = "db2+ibm_db://openmetadata_user:@localhost:50000"
expected_url = "db2+ibm_db://openmetadata_user:@localhost:50000/testdb"
db2_conn_obj = Db2Connection(
scheme=Db2Scheme.db2_ibm_db,
username="openmetadata_user",
hostPort="localhost:50000",
scheme=Db2Scheme.db2_ibm_db,
database="testdb",
)
assert expected_url == get_connection_url(db2_conn_obj)
@ -720,6 +712,7 @@ class SouceConnectionTest(TestCase):
hostPort="localhost:443",
connectionArguments=None,
scheme=Db2Scheme.db2_ibm_db,
database="testdb",
)
assert expected_args == get_connection_args(db2_conn_obj)
@ -731,6 +724,7 @@ class SouceConnectionTest(TestCase):
hostPort="localhost:443",
connectionArguments={"user": "user-to-be-impersonated"},
scheme=Db2Scheme.db2_ibm_db,
database="testdb",
)
assert expected_args == get_connection_args(db2_conn_obj)

View File

@ -76,7 +76,7 @@
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Profiler",
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
}
},

View File

@ -48,9 +48,9 @@
"description": "Host and port of the DB2 service.",
"type": "string"
},
"databaseSchema": {
"title": "databaseSchema",
"description": "databaseSchema of the data source. This is optional parameter, if you would like to restrict the metadata reading to a single databaseSchema. When left blank, OpenMetadata Ingestion attempts to scan all the databaseSchema.",
"database": {
"title": "database",
"description": "Database of the data source.",
"type": "string"
},
"connectionOptions": {
@ -69,11 +69,15 @@
"title": "Supports Profiler",
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {
"title": "Supports Query Comment",
"$ref": "../connectionBasicType.json#/definitions/supportsQueryComment"
}
},
"additionalProperties": false,
"required": ["hostPort", "username"]
"required": ["hostPort", "username", "database"]
}

View File

@ -76,7 +76,7 @@
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Profiler",
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {

View File

@ -75,7 +75,7 @@
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Profiler",
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {

View File

@ -82,7 +82,7 @@
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Profiler",
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {

View File

@ -103,7 +103,7 @@
"$ref": "../connectionBasicType.json#/definitions/supportsProfiler"
},
"supportsDatabase": {
"title": "Supports Profiler",
"title": "Supports Database",
"$ref": "../connectionBasicType.json#/definitions/supportsDatabase"
},
"supportsQueryComment": {