-
Notifications
You must be signed in to change notification settings - Fork 43
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
Allow list and tuples as columns names in Append & Merge #450
Conversation
Codecov Report
@@ Coverage Diff @@
## main #450 +/- ##
==========================================
+ Coverage 90.97% 91.04% +0.06%
==========================================
Files 41 41
Lines 1319 1329 +10
Branches 168 172 +4
==========================================
+ Hits 1200 1210 +10
Misses 99 99
Partials 20 20
Continue to review full report at Codecov.
|
addresses #439 (comment) Tt feels tedious and probably most of the times the col names would be the same. This commit renames `source_to_target_columns_map` param in Append and Merge operator to `columns` and allows passing either a) list or tuples containing col names b) dict containing source to target mapping. Before: ```python append( source_table=filtered_data, target_table=Table(name="homes_reporting", conn_id=SNOWFLAKE_CONN_ID), source_to_target_columns_map={ "sell": "sell", "list": "list", "variable": "variable", "value": "value", }, ) ``` After: ```python append( source_table=filtered_data, target_table=Table(name="homes_reporting", conn_id=SNOWFLAKE_CONN_ID), columns=["sell", "list", "variable", "value"] ) ```
task_id: str = "", | ||
**kwargs: Any, | ||
) -> None: | ||
self.source_table = source_table | ||
self.target_table = target_table | ||
self.source_to_target_columns_map = source_to_target_columns_map or {} | ||
|
||
if isinstance(columns, (list, tuple)): |
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.
Hey @kaxil, nothing major, but can we move lines 36 - 41 to a function and use that function in the append and merge operators just to avoid some code duplication?
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.
In this case, DAMP (“Descriptive and Meaningful Phrases”) approach is better than DRY (“Don’t Repeat Yourself”) as they are hardly 4-5 lines :)
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.
LGTM
addresses #439 (comment)
Tt feels tedious and probably most of the times the col names would be the same. This commit renames
source_to_target_columns_map
param in Append and Merge operator tocolumns
and allows passing either a) list or tuples containing col names b) dict containing source to target mapping.Before:
After:
ToDo: