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
Column creation and duplication DDL 2 #2978
Conversation
To the reviewer: It's probable that we still need to remove more python layer tests, or rework some fixtures. I think we should leave the bulk of test refactoring till after the functionality is complete. |
END LOOP; | ||
RETURN format('%s %s', original_col_name, idx); | ||
END; | ||
$$ LANGUAGE plpgsql RETURNS NULL ON NULL INPUT; |
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.
I would have been happy with the SQL version, but I think it's smart to dumb-down non-critical code 👍.
format_type(atttypid, atttypmod), | ||
-- set the duplicate column to be nullable, since it will initially be empty | ||
false, | ||
-- set set the default value for the duplicate column if specified |
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.
These comments are very useful.
FROM pg_attribute AS pg_columns | ||
JOIN unnest(col_ids, new_names) AS columns_to_copy(col_id, new_name) | ||
ON pg_columns.attnum=columns_to_copy.col_id | ||
LEFT JOIN pg_attrdef AS pg_column_defaults |
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.
Finding these aliases useful.
END, | ||
', ' | ||
) AS not_nulls | ||
FROM unnest(not_null_defs) as col | ||
FROM unnest(not_null_defs) as not_null_def |
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.
👍
Co-authored-by: Dominykas Mostauskis <2715476+dmos62@users.noreply.github.com>
Related to #2690
This PR is another step in moving column creation/duplication DDL operations to the database.
Technical details
column_copy
function at the SQL layer, uses it in pythonTODO
There is still a 'bulk create' function for columns in the python layer:
This function won't be replaced, but will be deleted entirely when moving the table splitting/merging/column moving logic to the DB. So, we've skipped it for now.
Checklist
Update index.md
).develop
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin