Skip to content

Commit

Permalink
Update get_columns_list() to accept tables with spaces in the name (#973
Browse files Browse the repository at this point in the history
)

* handle table names with spaces or invalid characters

* handle instances where quotes already exist around table and schema names

---------

Co-authored-by: Erica Renée Faulkenberry <erica@Ericas-MacBook-Pro-M3.local>
  • Loading branch information
coastlines and Erica Renée Faulkenberry authored Jan 24, 2024
1 parent 94e8ec8 commit 54c5d74
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions parsons/databases/redshift/rs_table_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ def get_columns_list(self, schema, table_name):
`Returns:`
A list of column names.
"""
schema = (
f'"{schema}"'
if not (schema.startswith('"') and schema.endswith('"'))
else schema
)

table_name = (
f'"{table_name}"'
if not (table_name.startswith('"') and table_name.endswith('"'))
else table_name
)

first_row = self.query(f"select * from {schema}.{table_name} limit 1")

Expand Down

0 comments on commit 54c5d74

Please sign in to comment.