Skip to content

Conversation

@sfc-gh-fpawlowski
Copy link
Contributor

SNOW-1675422-implement-write-pandas-in-async-io-version

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes #NNNN

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

  4. (Optional) PR for stored-proc connector:

@sfc-gh-fpawlowski sfc-gh-fpawlowski self-assigned this Nov 5, 2025
len(copy_results),
sum(int(e[3]) for e in copy_results),
copy_results,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pd_writer and make_pd_writer were skipped, since Pandas.to_sql does not support async operations anyway. We could consider using get_running_loop or creating a new loop inside the pd_writer function to run the whole async write_pandas in sync pandas.to_sql - but I am not sure if we should promise to deliver such interface with such behaviour right now - it may be unstable. Also overhead for spinning up the loop may be noticeable.

use_scoped_temp_object: bool,
) -> None:
create_stage_sql = f"CREATE {get_temp_type_for_object(use_scoped_temp_object)} STAGE /* Python:snowflake.connector.aio._pandas_tools.write_pandas() */ identifier(?) FILE_FORMAT=(TYPE=PARQUET COMPRESSION={compression}{' BINARY_AS_TEXT=FALSE' if auto_create_table or overwrite else ''})"
params = (stage_location,)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any chances we can bind compression type? Just to avoid sql incjection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, created jira to fix that in sync code as well: https://snowflakecomputing.atlassian.net/browse/SNOW-2690895

Copy link
Contributor Author

@sfc-gh-fpawlowski sfc-gh-fpawlowski Nov 12, 2025

Choose a reason for hiding this comment

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

Actually on a second thought - I think it is already addressed by:

    compression_map = {"gzip": "auto", "snappy": "snappy"}
    if compression not in compression_map.keys():
        raise ProgrammingError(
            f"Invalid compression '{compression}', only acceptable values are: {compression_map.keys()}"
        )

in write_pandas

)

if create_temp_table:
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider removing any deprecation warnings from aio code? The async io version is a new API and we can take advantage of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I think we can make such decision and remove it from here.

@sfc-gh-fpawlowski sfc-gh-fpawlowski force-pushed the SNOW-1675422-implement-write-pandas-in-async-io-version branch from ef96cc1 to 6109387 Compare November 12, 2025 10:53
Copy link
Contributor

@sfc-gh-turbaszek sfc-gh-turbaszek left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@sfc-gh-fpawlowski sfc-gh-fpawlowski merged commit dbcae65 into dev/aio-connector Nov 12, 2025
13 of 19 checks passed
@sfc-gh-fpawlowski sfc-gh-fpawlowski deleted the SNOW-1675422-implement-write-pandas-in-async-io-version branch November 12, 2025 16:35
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants