Skip to content

SNOW-1184290: Skip CREATE TABLE IF NOT EXISTS when auto_create_table#2791

Open
sfc-gh-turbaszek wants to merge 7 commits intomainfrom
SNOW-1184290-write-pandas-no-create-table-on-overwrite
Open

SNOW-1184290: Skip CREATE TABLE IF NOT EXISTS when auto_create_table#2791
sfc-gh-turbaszek wants to merge 7 commits intomainfrom
SNOW-1184290-write-pandas-no-create-table-on-overwrite

Conversation

@sfc-gh-turbaszek
Copy link
Copy Markdown
Contributor

write_pandas() with auto_create_table=False and overwrite=True was executing CREATE TABLE IF NOT EXISTS before TRUNCATE, which requires OWNERSHIP privilege on the table. When auto_create_table=False, the table is assumed to already exist so only TRUNCATE is needed.

Changed the condition guarding CREATE TABLE from
if auto_create_table or overwrite to if auto_create_table in both the sync and async implementations. Added unit tests to verify the SQL statements emitted for each combination of overwrite and auto_create_table.

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-turbaszek sfc-gh-turbaszek marked this pull request as ready for review March 18, 2026 08:43
@sfc-gh-turbaszek sfc-gh-turbaszek requested a review from a team as a code owner March 18, 2026 08:43
Copy link
Copy Markdown
Contributor

@sfc-gh-fpawlowski sfc-gh-fpawlowski left a comment

Choose a reason for hiding this comment

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

Looks good 👍

sfc-gh-turbaszek and others added 3 commits March 18, 2026 19:06
…False

write_pandas() with auto_create_table=False and overwrite=True was
executing CREATE TABLE IF NOT EXISTS before TRUNCATE, which requires
OWNERSHIP privilege on the table. When auto_create_table=False, the
table is assumed to already exist so only TRUNCATE is needed.

Changed the condition guarding CREATE TABLE from
`if auto_create_table or overwrite` to `if auto_create_table` in both
the sync and async implementations. Added unit tests to verify the
SQL statements emitted for each combination of overwrite and
auto_create_table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…False

write_pandas() with auto_create_table=False and overwrite=True was
executing CREATE TABLE IF NOT EXISTS before TRUNCATE, which requires
OWNERSHIP privilege on the table. When auto_create_table=False, the
table is assumed to already exist so only TRUNCATE is needed.

Changed the condition guarding CREATE TABLE from
`if auto_create_table or overwrite` to `if auto_create_table` in both
the sync and async implementations. Added unit tests to verify the
SQL statements emitted for each combination of overwrite and
auto_create_table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unused `call` import and apply black formatting to test_pandas_tools.py
- Add corresponding async unit tests in test/unit/aio/test_pandas_tools_async.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sfc-gh-turbaszek sfc-gh-turbaszek force-pushed the SNOW-1184290-write-pandas-no-create-table-on-overwrite branch from 63be2e7 to 45698aa Compare March 18, 2026 18:07
sfc-gh-turbaszek and others added 4 commits March 19, 2026 09:23
…False

write_pandas() with auto_create_table=False and overwrite=True was
executing CREATE TABLE IF NOT EXISTS before TRUNCATE, which requires
OWNERSHIP privilege on the table. When auto_create_table=False, the
table is assumed to already exist so only TRUNCATE is needed.

Changed the condition guarding CREATE TABLE from
`if auto_create_table or overwrite` to `if auto_create_table` in both
the sync and async implementations. Added unit tests to verify the
SQL statements emitted for each combination of overwrite and
auto_create_table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The unit tests were failing in non-pandas tox environments because
the module-level pandas import raised MissingDependencyError. Use
pytest.importorskip to skip collection and add @pytest.mark.pandas
+ @pytest.mark.unit to route tests to the pandas-parallel environment.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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