Fix #1665: Oracle connector add an option to configure oracle service name (#1666)

* Fix #1665: Oracle connector add an option to configure oracle service name

* Fixed removal of semi colon

Fixes SQL Command Warning while ingesting

Co-authored-by: Akash Jain <15995028+akash-jain-10@users.noreply.github.com>
This commit is contained in:
Sriharsha Chintalapani 2021-12-10 03:07:19 -08:00 committed by GitHub
parent ec7ff6fa13
commit 7b637d4628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,25 @@
{
"source": {
"type": "oracle",
"config": {
"host_port":"host:1521",
"username": "pdbadmin",
"password": "password",
"service_name": "local_oracle",
"service_type": "Oracle",
"oracle_service_name": "ORCLPDB1"
}
},
"sink": {
"type": "metadata-rest",
"config": {
}
},
"metadata_server": {
"type": "metadata-server",
"config": {
"api_endpoint": "http://localhost:8585/api",
"auth_provider_type": "no-auth"
}
}
}

View File

@ -10,7 +10,10 @@
# limitations under the License.
# This import verifies that the dependencies are available.
from typing import Optional
import cx_Oracle # noqa: F401
import pydantic
from metadata.ingestion.ometa.openmetadata_rest import MetadataServerConfig
from metadata.ingestion.source.sql_source import SQLConnectionConfig, SQLSource
@ -19,9 +22,23 @@ from metadata.ingestion.source.sql_source import SQLConnectionConfig, SQLSource
class OracleConfig(SQLConnectionConfig):
# defaults
scheme = "oracle+cx_oracle"
oracle_service_name: Optional[str] = None
query: Optional[str] = "select * from {}.{} where ROWNUM <= 50"
@pydantic.validator("oracle_service_name")
def check_oracle_service_name(cls, v, values):
if values.get("database") and v:
raise ValueError(
"Please provide database or oracle_service_name but not both"
)
return v
def get_connection_url(self):
return super().get_connection_url()
url = super().get_connection_url()
if self.oracle_service_name:
assert not self.database
url = f"{url}/?service_name={self.oracle_service_name}"
return url
class OracleSource(SQLSource):