Skip to content

Commit

Permalink
fix(ingest/mssql): Add UNIQUEIDENTIFIER data type as String (#8642)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Sikowitz <andrew.sikowitz@acryl.io>
  • Loading branch information
cjm98332 and asikowitz authored Sep 12, 2023
1 parent aee1e68 commit a021053
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@
BasicSQLAlchemyConfig,
make_sqlalchemy_uri,
)
from datahub.metadata.schema_classes import BooleanTypeClass, UnionTypeClass
from datahub.metadata.schema_classes import (
BooleanTypeClass,
StringTypeClass,
UnionTypeClass,
)

logger: logging.Logger = logging.getLogger(__name__)

register_custom_type(sqlalchemy.dialects.mssql.BIT, BooleanTypeClass)
register_custom_type(sqlalchemy.dialects.mssql.SQL_VARIANT, UnionTypeClass)
register_custom_type(sqlalchemy.dialects.mssql.UNIQUEIDENTIFIER, StringTypeClass)


class SQLServerConfig(BasicSQLAlchemyConfig):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,18 @@
"recursive": false,
"isPartOfKey": true
},
{
"fieldPath": "SomeId",
"nullable": false,
"type": {
"type": {
"com.linkedin.pegasus2avro.schema.StringType": {}
}
},
"nativeDataType": "UNIQUEIDENTIFIER()",
"recursive": false,
"isPartOfKey": false
},
{
"fieldPath": "Name",
"nullable": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,18 @@
"recursive": false,
"isPartOfKey": true
},
{
"fieldPath": "SomeId",
"nullable": false,
"type": {
"type": {
"com.linkedin.pegasus2avro.schema.StringType": {}
}
},
"nativeDataType": "UNIQUEIDENTIFIER()",
"recursive": false,
"isPartOfKey": false
},
{
"fieldPath": "Name",
"nullable": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,18 @@
"recursive": false,
"isPartOfKey": true
},
{
"fieldPath": "SomeId",
"nullable": false,
"type": {
"type": {
"com.linkedin.pegasus2avro.schema.StringType": {}
}
},
"nativeDataType": "UNIQUEIDENTIFIER()",
"recursive": false,
"isPartOfKey": false
},
{
"fieldPath": "Name",
"nullable": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,18 @@
"recursive": false,
"isPartOfKey": true
},
{
"fieldPath": "SomeId",
"nullable": false,
"type": {
"type": {
"com.linkedin.pegasus2avro.schema.StringType": {}
}
},
"nativeDataType": "UNIQUEIDENTIFIER()",
"recursive": false,
"isPartOfKey": false
},
{
"fieldPath": "Name",
"nullable": true,
Expand Down
27 changes: 14 additions & 13 deletions metadata-ingestion/tests/integration/sql_server/setup/setup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ CREATE TABLE Foo.Persons (
GO
CREATE TABLE Foo.SalesReason
(
TempID int NOT NULL,
TempID int NOT NULL,
SomeId UNIQUEIDENTIFIER NOT NULL DEFAULT NEWID(),
Name nvarchar(50)
, CONSTRAINT PK_TempSales PRIMARY KEY NONCLUSTERED (TempID)
, CONSTRAINT FK_TempSales_SalesReason FOREIGN KEY (TempID)
Expand All @@ -49,20 +50,20 @@ AS
SELECT @ID AS ThatDB;
GO

GO
EXEC sys.sp_addextendedproperty
@name = N'MS_Description',
@value = N'Description for table Items of schema Foo.',
@level0type = N'SCHEMA', @level0name = 'Foo',
@level1type = N'TABLE', @level1name = 'Items';
GO
EXEC sys.sp_addextendedproperty
@name = N'MS_Description',
@value = N'Description for table Items of schema Foo.',
@level0type = N'SCHEMA', @level0name = 'Foo',
@level1type = N'TABLE', @level1name = 'Items';
GO

GO
EXEC sys.sp_addextendedproperty
@name = N'MS_Description',
@value = N'Description for column LastName of table Persons of schema Foo.',
@level0type = N'SCHEMA', @level0name = 'Foo',
@level1type = N'TABLE', @level1name = 'Persons',
GO
EXEC sys.sp_addextendedproperty
@name = N'MS_Description',
@value = N'Description for column LastName of table Persons of schema Foo.',
@level0type = N'SCHEMA', @level0name = 'Foo',
@level1type = N'TABLE', @level1name = 'Persons',
@level2type = N'COLUMN',@level2name = 'LastName';
GO
USE msdb ;
Expand Down

0 comments on commit a021053

Please sign in to comment.