Skip to content

SNOW-2912540: inline _create_temp_stage and _create_temp_file_format into analyzer_utils - #4308

Open
sfc-gh-fpawlowski wants to merge 3 commits into
SNOW-2912540-remove-connector-shimsfrom
SNOW-2912540-inline-pandas-staging-helpers
Open

SNOW-2912540: inline _create_temp_stage and _create_temp_file_format into analyzer_utils#4308
sfc-gh-fpawlowski wants to merge 3 commits into
SNOW-2912540-remove-connector-shimsfrom
SNOW-2912540-inline-pandas-staging-helpers

Conversation

@sfc-gh-fpawlowski

@sfc-gh-fpawlowski sfc-gh-fpawlowski commented Aug 6, 2026

Copy link
Copy Markdown

Ports the _create_temp_stage and _create_temp_file_format implementations from the Universal Driver connector (PR snowflake-eng/drivers#518) directly into Snowpark's analyzer_utils.py, removing the dependency on these private snowflake.connector.pandas_tools symbols.

Changes:

  • analyzer_utils.py: Remove the three connector imports (_create_temp_stage, _create_temp_file_format, build_location_helper). Add local implementations of all staging helpers: _qualify_name / build_location_helper, _pandas_generate_temp_name, _pandas_create_temp_object, _stage_sql, _file_format_sql, _create_temp_stage, _create_temp_file_format.
  • Fix the _create_temp_file_format call site in write_arrow: the local impl maps compression internally (like PR SNOW-667858: to_pandas will only convert TimestampTypes to a native pandas date format, and not DateTypes #518), so the caller no longer pre-maps via compression_map[compression].
  • black-format the ported code, and suppress a pyright overload error on the two cursor.execute(..., _force_qmark_paramstyle=True) calls in _pandas_create_temp_object: _force_qmark_paramstyle is declared only on SnowflakeCursor.execute's real implementation signature in snowflake-connector-python, not on either of its two @overload stubs — a latent stub gap invisible while this code lived inside the connector package, now exposed since it lives in Snowpark's own pyright-checked source tree.

Companion: snowflake-eng/drivers#518 (which implements the same functions in the UD connector for its own write_pandas flow — the two implementations are kept in sync).

Checklist

  • I acknowledge that I have ensured my changes to be thread-safe

Stack (via Graphite)

🤖 Generated with Claude Code

sfc-gh-fpawlowski commented Aug 6, 2026

Copy link
Copy Markdown
Author

@codecov-commenter

codecov-commenter commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.24390% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.34%. Comparing base (b245fcd) to head (4292ad1).

Files with missing lines Patch % Lines
...lake/snowpark/_internal/analyzer/analyzer_utils.py 90.24% 4 Missing ⚠️
Additional details and impacted files
@@                           Coverage Diff                           @@
##           SNOW-2912540-remove-connector-shims    #4308      +/-   ##
=======================================================================
- Coverage                                95.46%   95.34%   -0.13%     
=======================================================================
  Files                                      171      171              
  Lines                                    44719    44758      +39     
  Branches                                  7676     7678       +2     
=======================================================================
- Hits                                     42693    42673      -20     
- Misses                                    1253     1306      +53     
- Partials                                   773      779       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sfc-gh-fpawlowski and others added 3 commits August 21, 2026 08:24
…into analyzer_utils

Removes the dependency on these private snowflake-connector-python functions
(previously imported from connector.pandas_tools). Ports the implementation
from universal-driver PR #518 directly into Snowpark so the connector no longer
needs to expose staging helpers as part of its public surface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ned pandas staging helpers

black never ran on the ported code (4 blocks needed line-wrapping).
The two cursor.execute(..., _force_qmark_paramstyle=True) calls also
fail pyright: SnowflakeCursor.execute's two @overload stubs in
snowflake-connector-python never declare _force_qmark_paramstyle,
only the real implementation signature does. That gap was invisible
while this code lived in the connector package; porting it into
analyzer_utils.py exposes it to Snowpark's own pyright run.
…tings

_stage_sql (inlined from universal-driver PR #518 in the prior commit)
faithfully maps compression="gzip" to COMPRESSION=auto in the generated
CREATE...STAGE...FILE_FORMAT SQL, same as it already does for the COPY INTO
clause (see copy_compression in this test). The stage-creation assertion
still expected the literal "gzip", unlike its COPY INTO counterpart a few
lines below which already accounted for the auto mapping via
copy_compression. Update it to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants