Skip to content

SNOW-4537762: Reuse the JDBC connection across process() calls in DataFrameReader.jdbc - #4518

Open
sfc-gh-yuwang wants to merge 3 commits into
mainfrom
yuwang/SNOW-4537762-jdbc-handler-reuse
Open

sfc-gh-yuwang wants to merge 3 commits into
mainfrom
yuwang/SNOW-4537762-jdbc-handler-reuse

Conversation

@sfc-gh-yuwang

Copy link
Copy Markdown
Collaborator

Stacked on #4515 (part of the read.jdbc() GA epic SNOW-4522813). Review only the top commit.

Summary

Snowflake can route several partition rows to one UDTF handler instance, so the
read UDTF must not close its connection after the first partition. Open the
connection lazily, close per-call statements/result sets on exhaustion or error,
and close the connection in endPartition(). The infer-schema UDTF now also
closes its connection on error.

Test plan

  • tests/unit/test_data_source.py (new regression tests fail without the fix)
  • tests/integ/datasource/test_jdbc.py against live Oracle, PostgreSQL, MySQL and SQL Server (42 passed on the stack tip)

Generated with Snowflake CoCo

sfc-gh-yuwang and others added 3 commits November 16, 2026 13:50
read.jdbc() embedded the user query unescaped inside a SQL string literal
when calling the infer-schema UDTF, so any query= containing string
literals, backslashes or newlines failed (or was silently altered).
Escape it with str_to_sql; the ingestion path is unchanged.

Generated with [Snowflake CoCo](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code)

Co-authored-by: Snowflake CoCo <noreply@snowflake.com>
…dbc-query-literals

# Conflicts:
#	CHANGELOG.md
…aFrameReader.jdbc

Snowflake can route several partition rows to one UDTF handler instance, so the
read UDTF must not close its connection after the first partition. Open the
connection lazily, close per-call statements/result sets on exhaustion or error,
and close the connection in endPartition(). The infer-schema UDTF now also
closes its connection on error.

Generated with [Snowflake CoCo](https://docs.snowflake.com/en/user-guide/cortex-code/cortex-code)

Co-authored-by: Snowflake CoCo <noreply@snowflake.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.55%. Comparing base (f5c5f7c) to head (43f28ae).

Additional details and impacted files
@@                           Coverage Diff                            @@
##           yuwang/SNOW-4522827-jdbc-query-literals    #4518   +/-   ##
========================================================================
  Coverage                                    95.55%   95.55%           
========================================================================
  Files                                          179      179           
  Lines                                        47039    47039           
  Branches                                      8140     8140           
========================================================================
  Hits                                         44947    44947           
  Misses                                        1304     1304           
  Partials                                       788      788           

☔ 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.

Base automatically changed from yuwang/SNOW-4522827-jdbc-query-literals to main November 18, 2026 23:49
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