Skip to content

Commit

Permalink
Fix vertica comments for version 9 (open-metadata#11479)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulixius9 authored May 8, 2023
1 parent 074418e commit ddc3060
Showing 1 changed file with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,39 @@
# So to fetch column comments we need to concat the table_name + projection infix + column name.
# Example: querying `v_catalog.comments` we find an object_name for a column in the table vendor_dimension as
# `vendor_dimension_super.vendor_name`. Note how this is the `_super` projection.
# Then, our join looks for the match in `vendor_dimension_%.vendor_name`.
# Then, our join looks for the match in `vendor_dimension_super.vendor_name`.
# In case there are more than one projections available for a table then we pick up
# comments from any one projection available for table
# Note: This might not suit for all column scenarios, but currently we did not find a better way to join
# v_catalog.comments with v_catalog.columns.
VERTICA_GET_COLUMNS = textwrap.dedent(
"""
SELECT
WITH
column_projection as
(SELECT
column_name,
data_type,
column_default,
is_nullable,
table_name,
table_schema,
proj.projection_name
FROM v_catalog.columns col,
v_catalog.projections proj
where proj.projection_id in (select
min(projection_id)
from v_catalog.projections sub_proj
where col.table_id=sub_proj.anchor_table_id
))
select
column_name,
data_type,
column_default,
is_nullable,
comment
FROM v_catalog.columns col
comment from column_projection col
LEFT JOIN v_catalog.comments com
ON com.object_type = 'COLUMN'
AND com.object_id = col.table_id
AND com.child_object = col.column_name
AND com.object_name = CONCAT(CONCAT(col.projection_name,'.'),col.column_name)
WHERE lower(table_name) = '{table}'
AND {schema_condition}
UNION ALL
Expand Down

0 comments on commit ddc3060

Please sign in to comment.