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

Update fetch_r_script_checksum to iterate over multiple results batches within a cursor #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

*The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).*

## [3.4.2] - 2022-06-14
### Fixed
- Updated fetch_r_script_checksum method in the CLI to iterate over multiple results batches within a single cursor. This protects against failure in the case where the R-script results are large enough to require multiple batches. Ref snowflake-python-connector documentation here: https://docs.snowflake.com/en/user-guide/python-connector-api.html#get_result_batches

## [3.4.1] - 2021-12-08
### Added
- Added a new optional parameter `--query-tag` to append a string to the QUERY_TAG that is attached to every SQL statement executed
Expand Down
10 changes: 6 additions & 4 deletions schemachange/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from cryptography.hazmat.primitives import serialization

# Set a few global variables here
_schemachange_version = '3.4.1'
_schemachange_version = '3.4.2'
_config_file_name = 'schemachange-config.yml'
_metadata_database_name = 'METADATA'
_metadata_schema_name = 'SCHEMACHANGE'
Expand Down Expand Up @@ -614,9 +614,11 @@ def fetch_r_scripts_checksum(change_history_table, snowflake_session_parameters,
script_names = []
checksums = []
for cursor in results:
for row in cursor:
script_names.append(row[0])
checksums.append(row[1])
batches = cursor.get_result_batches()
for batch in batches:
for row in batch:
script_names.append(row[0])
checksums.append(row[1])

d_script_checksum['script_name'] = script_names
d_script_checksum['checksum'] = checksums
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = schemachange
version = 3.4.1
version = 3.4.2
author = jamesweakley/jeremiahhansen
description = A Database Change Management tool for Snowflake
long_description = file: README.md
Expand All @@ -20,6 +20,7 @@ install_requires =
pandas~=1.3
Copy link
Author

@gcnuss gcnuss Jun 14, 2022

Choose a reason for hiding this comment

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

I'm curious why the install_requires are set to "~=" instead of >= or with upper/lower bounds like I added for pyarrow. I couldn't find other examples using this online, what is the purpose of that approach?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gcnuss The pattern is aligned to this reference.

pyyaml~=5.4
jinja2~=3.0
pyarrow>=6.0.0,<6.1.0
include_package_data = True

[options.entry_points]
Expand Down