mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-26 09:22:14 +00:00
Fixes ISSUE-13473: Ensure MSSQL columns query filters to tables and views (#15530)
* Update queries.py and utils.py to ingest table and view descriptions * Ensure MSSQL columns query filters to tables and views * Fix linters --------- Co-authored-by: Pablo Takara <pjt1991@gmail.com>
This commit is contained in:
parent
a87161a9ed
commit
34b727f6c9
@ -46,27 +46,27 @@ MSSQL_GET_TABLE_COMMENTS = textwrap.dedent(
|
|||||||
SELECT obj.name AS table_name,
|
SELECT obj.name AS table_name,
|
||||||
ep.value AS table_comment,
|
ep.value AS table_comment,
|
||||||
s.name AS "schema"
|
s.name AS "schema"
|
||||||
FROM sys.tables AS obj
|
FROM sys.objects AS obj
|
||||||
LEFT JOIN sys.extended_properties AS ep
|
LEFT JOIN sys.extended_properties AS ep
|
||||||
ON obj.object_id = ep.major_id AND ep.minor_id = 0
|
ON obj.object_id = ep.major_id AND ep.minor_id = 0 AND ep.name = 'MS_Description'
|
||||||
JOIN sys.schemas AS s
|
JOIN sys.schemas AS s
|
||||||
ON obj.schema_id = s.schema_id
|
ON obj.schema_id = s.schema_id
|
||||||
WHERE ep.name = 'MS_Description'
|
WHERE
|
||||||
|
obj.type IN ('U', 'V') /* User tables and views */
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
MSSQL_ALL_VIEW_DEFINITIONS = textwrap.dedent(
|
MSSQL_ALL_VIEW_DEFINITIONS = textwrap.dedent(
|
||||||
"""
|
"""
|
||||||
select
|
SELECT
|
||||||
definition view_def,
|
definition view_def,
|
||||||
views.name view_name,
|
views.name view_name,
|
||||||
sch.name "schema"
|
sch.name "schema"
|
||||||
from sys.sql_modules as mod,
|
FROM sys.sql_modules as mod
|
||||||
sys.views as views,
|
INNER JOIN sys.views as views
|
||||||
sys.schemas as sch
|
ON mod.object_id = views.object_id
|
||||||
where
|
INNER JOIN sys.schemas as sch
|
||||||
mod.object_id=views.object_id and
|
ON views.schema_id = sch.schema_id
|
||||||
views.schema_id=sch.schema_id
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ def get_columns(
|
|||||||
Column("minor_id", Integer, primary_key=True),
|
Column("minor_id", Integer, primary_key=True),
|
||||||
Column("name", String, primary_key=True),
|
Column("name", String, primary_key=True),
|
||||||
Column("value", String),
|
Column("value", String),
|
||||||
|
Column("class_desc", String),
|
||||||
schema="sys",
|
schema="sys",
|
||||||
)
|
)
|
||||||
sys_columns = alias(
|
sys_columns = alias(
|
||||||
@ -181,6 +182,8 @@ def get_columns(
|
|||||||
onclause=sql.and_(
|
onclause=sql.and_(
|
||||||
extended_properties.c.major_id == sys_columns.c.object_id,
|
extended_properties.c.major_id == sys_columns.c.object_id,
|
||||||
extended_properties.c.minor_id == sys_columns.c.column_id,
|
extended_properties.c.minor_id == sys_columns.c.column_id,
|
||||||
|
extended_properties.c.class_desc == "OBJECT_OR_COLUMN",
|
||||||
|
extended_properties.c.name == "MS_Description",
|
||||||
),
|
),
|
||||||
isouter=True,
|
isouter=True,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user