Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ingest/mssql): Add UNIQUEIDENTIFIER data type as String #8642

Merged
merged 5 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading