Fix vertica comments for version 9 (#11479)

This commit is contained in:
Mayur Singal 2023-05-08 16:34:28 +05:30 committed by GitHub
parent 074418eac3
commit ddc3060184
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,22 +21,39 @@ import textwrap
# 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