Skip to content

Commit

Permalink
fix(ingest): mssql - support database_alias (#4523)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhu authored Mar 30, 2022
1 parent c79c778 commit 1bad3c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/sql/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def get_sql_alchemy_url(self):

def get_identifier(self, schema: str, table: str) -> str:
regular = f"{schema}.{table}"
if self.database_alias:
return f"{self.database_alias}.{regular}"
if self.database:
return f"{self.database}.{regular}"
return regular
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.dbo.Products,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.dbo.Products,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "container",
Expand All @@ -839,7 +839,7 @@
"auditHeader": null,
"proposedSnapshot": {
"com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": {
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.dbo.Products,PROD)",
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.dbo.Products,PROD)",
"aspects": [
{
"com.linkedin.pegasus2avro.common.Status": {
Expand All @@ -859,7 +859,7 @@
},
{
"com.linkedin.pegasus2avro.schema.SchemaMetadata": {
"schemaName": "DemoData.dbo.Products",
"schemaName": "DemoDataAlias.dbo.Products",
"platform": "urn:li:dataPlatform:mssql",
"version": 0,
"created": {
Expand Down Expand Up @@ -937,7 +937,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.dbo.Products,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.dbo.Products,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "subTypes",
Expand Down Expand Up @@ -1032,7 +1032,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Items,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Items,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "container",
Expand All @@ -1052,7 +1052,7 @@
"auditHeader": null,
"proposedSnapshot": {
"com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": {
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Items,PROD)",
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Items,PROD)",
"aspects": [
{
"com.linkedin.pegasus2avro.common.Status": {
Expand All @@ -1072,7 +1072,7 @@
},
{
"com.linkedin.pegasus2avro.schema.SchemaMetadata": {
"schemaName": "DemoData.Foo.Items",
"schemaName": "DemoDataAlias.Foo.Items",
"platform": "urn:li:dataPlatform:mssql",
"version": 0,
"created": {
Expand Down Expand Up @@ -1150,7 +1150,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Items,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Items,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "subTypes",
Expand All @@ -1169,7 +1169,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Persons,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Persons,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "container",
Expand All @@ -1189,7 +1189,7 @@
"auditHeader": null,
"proposedSnapshot": {
"com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": {
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Persons,PROD)",
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Persons,PROD)",
"aspects": [
{
"com.linkedin.pegasus2avro.common.Status": {
Expand All @@ -1209,7 +1209,7 @@
},
{
"com.linkedin.pegasus2avro.schema.SchemaMetadata": {
"schemaName": "DemoData.Foo.Persons",
"schemaName": "DemoDataAlias.Foo.Persons",
"platform": "urn:li:dataPlatform:mssql",
"version": 0,
"created": {
Expand Down Expand Up @@ -1321,7 +1321,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Persons,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Persons,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "subTypes",
Expand All @@ -1340,7 +1340,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.SalesReason,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.SalesReason,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "container",
Expand All @@ -1360,7 +1360,7 @@
"auditHeader": null,
"proposedSnapshot": {
"com.linkedin.pegasus2avro.metadata.snapshot.DatasetSnapshot": {
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.SalesReason,PROD)",
"urn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.SalesReason,PROD)",
"aspects": [
{
"com.linkedin.pegasus2avro.common.Status": {
Expand All @@ -1380,7 +1380,7 @@
},
{
"com.linkedin.pegasus2avro.schema.SchemaMetadata": {
"schemaName": "DemoData.Foo.SalesReason",
"schemaName": "DemoDataAlias.Foo.SalesReason",
"platform": "urn:li:dataPlatform:mssql",
"version": 0,
"created": {
Expand Down Expand Up @@ -1444,12 +1444,12 @@
{
"name": "FK_TempSales_SalesReason",
"foreignFields": [
"urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Persons,PROD),ID)"
"urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Persons,PROD),ID)"
],
"sourceFields": [
"urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.SalesReason,PROD),TempID)"
"urn:li:schemaField:(urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.SalesReason,PROD),TempID)"
],
"foreignDataset": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.Persons,PROD)"
"foreignDataset": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.Persons,PROD)"
}
]
}
Expand All @@ -1469,7 +1469,7 @@
{
"auditHeader": null,
"entityType": "dataset",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoData.Foo.SalesReason,PROD)",
"entityUrn": "urn:li:dataset:(urn:li:dataPlatform:mssql,DemoDataAlias.Foo.SalesReason,PROD)",
"entityKeyAspect": null,
"changeType": "UPSERT",
"aspectName": "subTypes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source:
password: test!Password
database: DemoData
host_port: localhost:51433
database_alias: DemoDataAlias
# use_odbc: True
# uri_args:
# driver: "ODBC Driver 17 for SQL Server"
Expand Down

0 comments on commit 1bad3c7

Please sign in to comment.