Skip to content
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

Improve the memory efficiency of process_results() override #1050

Merged
merged 3 commits into from
May 21, 2024

Conversation

peterallenwebb
Copy link
Contributor

@peterallenwebb peterallenwebb commented May 17, 2024

resolves #1053

Problem

The existing override of process_results() creates a full copy of query results.

Solution

Iterate over result rows to modify them one by one.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@cla-bot cla-bot bot added the cla:yes label May 17, 2024
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-snowflake contributing guide.

@peterallenwebb peterallenwebb marked this pull request as ready for review May 17, 2024 18:39
@peterallenwebb peterallenwebb requested a review from a team as a code owner May 17, 2024 18:39
dbt/adapters/snowflake/connections.py Show resolved Hide resolved
for row in rows:
fixed_row = []
for col in row:
if isinstance(col, datetime.datetime) and col.tzinfo:
offset = col.utcoffset()
assert offset is not None
offset_seconds = offset.total_seconds()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: offset_seconds = offset.total_seconds() or 0

offset_seconds = offset.total_seconds()
new_timezone = pytz.FixedOffset(offset_seconds // 60)
new_timezone = pytz.FixedOffset(int(offset_seconds // 60))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytz is no longer required as of 3.9+, let's try to remove the dependency here?

https://github.com/stub42/pytz/blob/master/src/README.rst#introduction

@mikealfare mikealfare merged commit 4ff6bdb into main May 21, 2024
18 checks passed
@mikealfare mikealfare deleted the paw/improve-process-override branch May 21, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Memory Efficiency of process_results() Override
3 participants