From 48015ea9c7b8c35832ea767c420d77f3f6cb74d5 Mon Sep 17 00:00:00 2001 From: Andrew Neuer Date: Mon, 26 Feb 2024 15:04:34 -0700 Subject: [PATCH 1/2] Update mssql_metadata_extractor.py Correct case so mssql extractor works with case sensitive instances --- .../extractor/mssql_metadata_extractor.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/databuilder/databuilder/extractor/mssql_metadata_extractor.py b/databuilder/databuilder/extractor/mssql_metadata_extractor.py index ce2d66e6a9..91ce3d1b68 100644 --- a/databuilder/databuilder/extractor/mssql_metadata_extractor.py +++ b/databuilder/databuilder/extractor/mssql_metadata_extractor.py @@ -31,29 +31,29 @@ class MSSQLMetadataExtractor(Extractor): {cluster_source} AS cluster, TBL.TABLE_SCHEMA AS [schema_name], TBL.TABLE_NAME AS [name], - CAST(PROP.VALUE AS NVARCHAR(MAX)) AS [description], + CAST(PROP.value AS NVARCHAR(MAX)) AS [description], COL.COLUMN_NAME AS [col_name], COL.DATA_TYPE AS [col_type], - CAST(PROP_COL.VALUE AS NVARCHAR(MAX)) AS [col_description], + CAST(PROP_COL.value AS NVARCHAR(MAX)) AS [col_description], COL.ORDINAL_POSITION AS col_sort_order FROM INFORMATION_SCHEMA.TABLES TBL INNER JOIN INFORMATION_SCHEMA.COLUMNS COL ON (COL.TABLE_NAME = TBL.TABLE_NAME AND COL.TABLE_SCHEMA = TBL.TABLE_SCHEMA ) - LEFT JOIN SYS.EXTENDED_PROPERTIES PROP - ON (PROP.MAJOR_ID = OBJECT_ID(TBL.TABLE_SCHEMA + '.' + TBL.TABLE_NAME) - AND PROP.MINOR_ID = 0 - AND PROP.NAME = 'MS_Description') - LEFT JOIN SYS.EXTENDED_PROPERTIES PROP_COL - ON (PROP_COL.MAJOR_ID = OBJECT_ID(TBL.TABLE_SCHEMA + '.' + TBL.TABLE_NAME) - AND PROP_COL.MINOR_ID = COL.ORDINAL_POSITION - AND PROP_COL.NAME = 'MS_Description') - WHERE TBL.TABLE_TYPE = 'base table' {where_clause_suffix} + LEFT JOIN sys.extended_properties PROP + ON (PROP.major_id = OBJECT_ID(TBL.TABLE_SCHEMA + '.' + TBL.TABLE_NAME) + AND PROP.minor_id = 0 + AND PROP.name = 'MS_Description') + LEFT JOIN sys.extended_properties PROP_COL + ON (PROP_COL.major_id = OBJECT_ID(TBL.TABLE_SCHEMA + '.' + TBL.TABLE_NAME) + AND PROP_COL.minor_id = COL.ORDINAL_POSITION + AND PROP_COL.name = 'MS_Description') + WHERE TBL.TABLE_TYPE = 'BASE TABLE' {where_clause_suffix} ORDER BY - CLUSTER, - SCHEMA_NAME, - NAME, - COL_SORT_ORDER + cluster, + schema_name, + name, + col_sort_order ; """ From a70dd7bc992fee4b99e17396739dea092e1d517a Mon Sep 17 00:00:00 2001 From: Andrew Neuer Date: Tue, 27 Feb 2024 07:45:28 -0700 Subject: [PATCH 2/2] minor change to add signed off requirement innocuous change to add signed off. Signed-off-by: Andrew Neuer --- databuilder/databuilder/extractor/mssql_metadata_extractor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/databuilder/databuilder/extractor/mssql_metadata_extractor.py b/databuilder/databuilder/extractor/mssql_metadata_extractor.py index 91ce3d1b68..e635098def 100644 --- a/databuilder/databuilder/extractor/mssql_metadata_extractor.py +++ b/databuilder/databuilder/extractor/mssql_metadata_extractor.py @@ -28,14 +28,14 @@ class MSSQLMetadataExtractor(Extractor): # SELECT statement from MS SQL to extract table and column metadata SQL_STATEMENT = """ SELECT DISTINCT - {cluster_source} AS cluster, + {cluster_source} AS [cluster], TBL.TABLE_SCHEMA AS [schema_name], TBL.TABLE_NAME AS [name], CAST(PROP.value AS NVARCHAR(MAX)) AS [description], COL.COLUMN_NAME AS [col_name], COL.DATA_TYPE AS [col_type], CAST(PROP_COL.value AS NVARCHAR(MAX)) AS [col_description], - COL.ORDINAL_POSITION AS col_sort_order + COL.ORDINAL_POSITION AS [col_sort_order] FROM INFORMATION_SCHEMA.TABLES TBL INNER JOIN INFORMATION_SCHEMA.COLUMNS COL ON (COL.TABLE_NAME = TBL.TABLE_NAME