-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Bump psycopg2 to psycopg3 for all Postgres components #4303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9cdceab
Makefile: Formatting
job-almekinders dca9c9a
Makefile: Exclude Snowflake tests for postgres offline store tests
job-almekinders fc65cfc
Bootstrap: Use conninfo
job-almekinders a3ea80d
Tests: Make connection string compatible with psycopg3
job-almekinders e53d9e6
Tests: Test connection type pool and singleton
job-almekinders 59cbd10
Global: Replace conn.set_session() calls to be psycopg3 compatible
job-almekinders 0f86e9e
Offline: Use psycopg3
job-almekinders cd91fdc
Online: Use psycopg3
job-almekinders 3504c77
Online: Restructure online_write_batch
job-almekinders 6e45f8e
Online: Use correct placeholder
job-almekinders c755fcd
Online: Handle bytes properly in online_read()
job-almekinders acd4a8f
Online: Whitespace
job-almekinders 36147ef
Online: Open ConnectionPool
job-almekinders d3fd7e7
Online: Add typehint
job-almekinders 0a9bced
Utils: Use psycopg3
job-almekinders af136da
Lint: Raise exceptions if cursor returned no columns or rows
job-almekinders 0926a15
Add comment on +psycopg string
job-almekinders 6514987
Docs: Remove mention of psycopg2
job-almekinders 915454c
Lint: Fix
job-almekinders d8e6619
Default to postgresql+psycopg and log warning
job-almekinders 3328530
Solve merge conflicts
job-almekinders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Lint: Raise exceptions if cursor returned no columns or rows
Add log statement Lint: Fix _to_arrow_internal Lint: Fix _get_entity_df_event_timestamp_range Update exception Use ZeroColumnQueryResult Signed-off-by: Job Almekinders <job.almekinders@teampicnic.com>
- Loading branch information
commit af136daf4d4abe7794ed016f2d48613b75219d8a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import contextlib | ||
| import logging | ||
| from dataclasses import asdict | ||
| from datetime import datetime | ||
| from typing import ( | ||
|
|
@@ -23,7 +24,7 @@ | |
| from pytz import utc | ||
|
|
||
| from feast.data_source import DataSource | ||
| from feast.errors import InvalidEntityType | ||
| from feast.errors import InvalidEntityType, ZeroColumnQueryResult, ZeroRowsQueryResult | ||
| from feast.feature_view import DUMMY_ENTITY_ID, DUMMY_ENTITY_VAL, FeatureView | ||
| from feast.infra.offline_stores import offline_utils | ||
| from feast.infra.offline_stores.contrib.postgres_offline_store.postgres_source import ( | ||
|
|
@@ -276,6 +277,8 @@ def _to_arrow_internal(self, timeout: Optional[int] = None) -> pa.Table: | |
| with _get_conn(self.config.offline_store) as conn, conn.cursor() as cur: | ||
| conn.read_only = True | ||
| cur.execute(query) | ||
| if not cur.description: | ||
| raise ZeroColumnQueryResult(query) | ||
|
job-almekinders marked this conversation as resolved.
|
||
| fields = [ | ||
| (c.name, pg_type_code_to_arrow(c.type_code)) | ||
| for c in cur.description | ||
|
|
@@ -331,16 +334,19 @@ def _get_entity_df_event_timestamp_range( | |
| entity_df_event_timestamp.max().to_pydatetime(), | ||
| ) | ||
| elif isinstance(entity_df, str): | ||
| # If the entity_df is a string (SQL query), determine range | ||
| # from table | ||
| # If the entity_df is a string (SQL query), determine range from table | ||
| with _get_conn(config.offline_store) as conn, conn.cursor() as cur: | ||
| ( | ||
| cur.execute( | ||
| f"SELECT MIN({entity_df_event_timestamp_col}) AS min, MAX({entity_df_event_timestamp_col}) AS max FROM ({entity_df}) as tmp_alias" | ||
| ), | ||
| ) | ||
| query = f""" | ||
| SELECT | ||
| MIN({entity_df_event_timestamp_col}) AS min, | ||
| MAX({entity_df_event_timestamp_col}) AS max | ||
| FROM ({entity_df}) AS tmp_alias | ||
| """ | ||
|
Comment on lines
+338
to
+343
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No updates here, only re-formatting the query |
||
| cur.execute(query) | ||
| res = cur.fetchone() | ||
| entity_df_event_timestamp_range = (res[0], res[1]) | ||
| if not res: | ||
| raise ZeroRowsQueryResult(query) | ||
| entity_df_event_timestamp_range = (res[0], res[1]) | ||
| else: | ||
| raise InvalidEntityType(type(entity_df)) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions to use for stricter handling of type hints of
psycopg3