Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4211f25
init impl
sfc-gh-aling May 10, 2025
fd46eb2
fix utc
sfc-gh-aling May 12, 2025
8aa988e
impl
sfc-gh-aling May 12, 2025
7e70380
Merge branch 'main' into SNOW-1955847-feat-add-support-to-postgresql
sfc-gh-aling May 12, 2025
62043f8
Apply suggestions from code review
sfc-gh-aling May 12, 2025
f76dd51
fix
sfc-gh-aling May 13, 2025
d10d338
Merge remote-tracking branch 'origin/SNOW-1955847-feat-add-support-to…
sfc-gh-aling May 13, 2025
25c475f
add test coverage
sfc-gh-aling May 13, 2025
462c558
update tox
sfc-gh-aling May 13, 2025
7fece89
Merge branch 'main' into SNOW-1955847-feat-add-support-to-postgresql
sfc-gh-aling May 13, 2025
bd25ddf
update tox
sfc-gh-aling May 14, 2025
599d8af
Merge remote-tracking branch 'origin/SNOW-1955847-feat-add-support-to…
sfc-gh-aling May 14, 2025
17f465e
try coverage
sfc-gh-aling May 14, 2025
e65ed57
Merge remote-tracking branch 'origin/main' into SNOW-1955847-feat-add…
sfc-gh-aling May 20, 2025
272dd7f
update
sfc-gh-aling May 21, 2025
d9671ed
update udtf dep
sfc-gh-aling May 21, 2025
a7b1b58
add unit test
sfc-gh-aling May 21, 2025
a6347e0
test dep
sfc-gh-aling May 21, 2025
b98f9b0
test psycopg2
sfc-gh-aling May 21, 2025
b94ed56
update changelog
sfc-gh-aling May 21, 2025
c8f6da6
install psycopg2 bin
sfc-gh-aling May 21, 2025
50628cf
update cred
sfc-gh-aling May 21, 2025
656faf7
update tox
sfc-gh-aling May 22, 2025
642dc32
temp skip test workflow
sfc-gh-aling May 22, 2025
e0477db
revert workflow change
sfc-gh-aling May 22, 2025
cceb8c3
Merge remote-tracking branch 'origin/main' into SNOW-1955847-feat-add…
sfc-gh-aling May 23, 2025
e3980eb
Update tox.ini
sfc-gh-aling May 23, 2025
98ef4d3
update test code
sfc-gh-aling May 23, 2025
f6e470b
Merge remote-tracking branch 'origin/SNOW-1955847-feat-add-support-to…
sfc-gh-aling May 23, 2025
3b6d885
Merge branch 'main' into SNOW-1955847-feat-add-support-to-postgresql
sfc-gh-aling May 24, 2025
c46c29e
Merge branch 'main' into SNOW-1955847-feat-add-support-to-postgresql
sfc-gh-aling May 24, 2025
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
Binary file modified .github/workflows/parameters/parameters_dbapi.py.gpg
Binary file not shown.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

### Snowpark Python API Updates

#### New Features

- Added PostgreSQL support to `DataFrameReader.dbapi` (PrPr) for both Parquet and UDTF-based ingestion.

#### Improvements

- Invoking snowflake system procedures does not invoke an additional `describe procedure` call to check the return type of the procedure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def read(self, partition: str) -> Iterator[List[Any]]:
yield result
elif self.fetch_size > 0:
cap_size = self.fetch_merge_count * self.fetch_size
cursor = cursor.execute(partition)
cursor.execute(partition)
batch = []
while True:
rows = cursor.fetchmany(self.fetch_size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"SqlServerDialect",
"OracledbDialect",
"DatabricksDialect",
"PostgresDialect",
]

from snowflake.snowpark._internal.data_source.dbms_dialects.base_dialect import (
Expand All @@ -24,3 +25,6 @@
from snowflake.snowpark._internal.data_source.dbms_dialects.databricks_dialect import (
DatabricksDialect,
)
from snowflake.snowpark._internal.data_source.dbms_dialects.postgresql_dialect import (
PostgresDialect,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2012-2025 Snowflake Computing Inc. All rights reserved.
#
from snowflake.snowpark._internal.data_source.dbms_dialects import BaseDialect


class PostgresDialect(BaseDialect):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"SqliteDriver",
"PyodbcDriver",
"DatabricksDriver",
"Psycopg2Driver",
]

from snowflake.snowpark._internal.data_source.drivers.base_driver import BaseDriver
Expand All @@ -19,3 +20,6 @@
from snowflake.snowpark._internal.data_source.drivers.databricks_driver import (
DatabricksDriver,
)
from snowflake.snowpark._internal.data_source.drivers.psycopg2_driver import (
Psycopg2Driver,
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def to_snow_type(self, schema: List[Any]) -> StructType:
f"{self.__class__.__name__} has not implemented to_snow_type function"
)

@staticmethod
def prepare_connection(
self,
conn: "Connection",
query_timeout: int = 0,
) -> "Connection":
Expand Down Expand Up @@ -81,7 +81,7 @@ def udtf_ingestion(
udtf_name = f"data_source_udtf_{generate_random_alphanumeric(5)}"
start = time.time()
session.udtf.register(
self.udtf_class_builder(fetch_size=fetch_size),
self.udtf_class_builder(fetch_size=fetch_size, schema=schema),
name=udtf_name,
output_schema=StructType(
[
Expand All @@ -104,7 +104,9 @@ def udtf_ingestion(
]
return res.select(cols)

def udtf_class_builder(self, fetch_size: int = 1000) -> type:
def udtf_class_builder(
self, fetch_size: int = 1000, schema: StructType = None
) -> type:
create_connection = self.create_connection

class UDTFIngestion:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def to_snow_type(self, schema: List[Any]) -> StructType:

return StructType(fields)

@staticmethod
def prepare_connection(
self,
conn: "Connection",
query_timeout: int = 0,
) -> "Connection":
Expand All @@ -119,7 +119,9 @@ def prepare_connection(
conn.outputtypehandler = output_type_handler
return conn

def udtf_class_builder(self, fetch_size: int = 1000) -> type:
def udtf_class_builder(
self, fetch_size: int = 1000, schema: StructType = None
) -> type:
create_connection = self.create_connection

def oracledb_output_type_handler(cursor, metadata):
Expand Down
Loading
Loading