-
Notifications
You must be signed in to change notification settings - Fork 0
[App Feature] [JsonSchema] Enabling the overriding of the catalog on the stream [LOYAL-10211] #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
973aa6a
da3639d
e9246f0
64bb702
cda49c5
58a4445
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -132,6 +132,25 @@ def ensure_test_table(table_spec, target_db='postgres'): | |||||||||||||||||||||||||||||||||
LOGGER.info("create table sql: %s", sql) | ||||||||||||||||||||||||||||||||||
cur.execute(sql) | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
def build_alter_table_sql(table, col_spec): | ||||||||||||||||||||||||||||||||||
sqls = [] | ||||||||||||||||||||||||||||||||||
if altered_name:=col_spec.get('change_name'): | ||||||||||||||||||||||||||||||||||
sqls.append("ALTER TABLE {} RENAME COLUMN {} TO {}".format(table, col_spec['name'], altered_name)) | ||||||||||||||||||||||||||||||||||
if altered_type:=col_spec.get('is_change_type'): | ||||||||||||||||||||||||||||||||||
sqls.append("ALTER TABLE {} ALTER COLUMN {} TYPE {}".format(table, col_spec['name'], altered_type)) | ||||||||||||||||||||||||||||||||||
if col_spec.get("is_new_col"): | ||||||||||||||||||||||||||||||||||
sqls.append("ALTER TABLE {} ADD {} {}".format(table, col_spec['name'], col_spec['type'])) | ||||||||||||||||||||||||||||||||||
return sqls | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
def alter_schema_test_table(table_spec, target_db='postgres'): | ||||||||||||||||||||||||||||||||||
with get_test_connection(target_db) as conn: | ||||||||||||||||||||||||||||||||||
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur: | ||||||||||||||||||||||||||||||||||
table = table_spec['name'] | ||||||||||||||||||||||||||||||||||
for col_spec in table_spec['columns']: | ||||||||||||||||||||||||||||||||||
for sql in build_alter_table_sql(quote_ident(table, cur), col_spec): | ||||||||||||||||||||||||||||||||||
LOGGER.info("alter table sql: %s", sql) | ||||||||||||||||||||||||||||||||||
cur.execute(sql) | ||||||||||||||||||||||||||||||||||
|
def alter_schema_test_table(table_spec, target_db='postgres'): | |
with get_test_connection(target_db) as conn: | |
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur: | |
table = table_spec['name'] | |
for col_spec in table_spec['columns']: | |
for sql in build_alter_table_sql(quote_ident(table, cur), col_spec): | |
LOGGER.info("alter table sql: %s", sql) | |
cur.execute(sql) | |
def add_columns(table_spec, target_db='postgres'): | |
with get_test_connection(target_db) as conn: | |
with conn.cursor(cursor_factory=psycopg2.extras.DictCursor) as cur: | |
table = table_spec['name'] | |
for col_name, col_type in table_spec['columns']: | |
sql = "ALTER TABLE {} ADD {} {}".format(table_name, col_name, col_type) | |
LOGGER.info("alter table sql: %s", sql) | |
cur.execute(sql) |
Nits
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more simpler if we explicitly
add_columns
in lieu of the genericsalter_schema_test_table
method ?As reviewer, I was trying to reading
alter_schema_test_table
to figure out that this method is actually adding new columns in this case 🤣There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay sir, i will change this and fix this in my next commit 😄