Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from transferwise/AP-256
Browse files Browse the repository at this point in the history
Some improvement
  • Loading branch information
louis-pie authored Jun 19, 2019
2 parents 27ee679 + f90ef84 commit 7f9132f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions target_snowflake/db_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,16 +503,13 @@ def get_tables(self, table_schema=None):
))

def get_table_columns(self, table_schema=None, table_name=None, filter_schemas=None):
return self.query("""SELECT LOWER(t.table_schema) table_schema, LOWER(t.table_name) table_name, c.column_name, c.data_type
FROM information_schema.tables t,
information_schema.columns c
WHERE t.table_type = 'BASE TABLE'
AND LOWER(c.table_schema) = {} AND LOWER(c.table_name) = {}
{}""".format(
"LOWER(t.table_schema)" if table_schema is None else "'{}'".format(table_schema.lower()),
"LOWER(t.table_name)" if table_name is None else "'{}'".format(table_name.lower()),
"" if not filter_schemas else " AND LOWER(c.table_schema) IN ({})".format(', '.join("'{0}'".format(s) for s in filter_schemas))
))
sql = """SELECT LOWER(c.table_schema) table_schema, LOWER(c.table_name) table_name, c.column_name, c.data_type
FROM information_schema.columns c
WHERE 1=1"""
if table_schema is not None: sql = sql + " AND LOWER(c.table_schema) = '" + table_schema.lower() + "'"
if table_name is not None: sql = sql + " AND LOWER(c.table_name) = '" + table_name.lower() + "'"
if filter_schemas is not None: sql = sql + " AND LOWER(c.table_schema) IN (" + ', '.join("'{}'".format(s).lower() for s in filter_schemas) + ")"
return self.query(sql)

def update_columns(self, table_columns_cache=None):
stream_schema_message = self.stream_schema_message
Expand Down

0 comments on commit 7f9132f

Please sign in to comment.