awslabs / amazon-redshift-utils

Amazon Redshift Utils contains utilities, scripts and view which are useful in a Redshift environment
Apache License 2.0
2.76k stars 1.25k forks source link

v_generate_tbl_ddl incorrectly pulls comments on tables with same name in different schema #707

Open mkellar3 opened 10 months ago

mkellar3 commented 10 months ago

v_generate_tbl_ddl pulls comments for tables with the same name in different schemas as the join to information_schema."columns" is only joining on table name. Correct this by adding a condition to join on schema as well as shown below:

OLD Line 273: ON cl.ordinal_position::integer = des.objsubid AND cl.table_name::NAME = c.relname

NEW Line 273: ON cl.ordinal_position::integer = des.objsubid AND cl.table_name::NAME = c.relname AND cl.table_schema = n.nspname