You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/02/04 02:59:10 UTC
[GitHub] [airflow] uranusjr commented on a change in pull request #21307: Fixed PostgresToGCSOperator fail on empty resultset for use_server_side_cursor=True
uranusjr commented on a change in pull request #21307:
URL: https://github.com/apache/airflow/pull/21307#discussion_r799129172
##########
File path: airflow/providers/google/cloud/transfers/postgres_to_gcs.py
##########
@@ -41,26 +41,22 @@ class _PostgresServerSideCursorDecorator:
def __init__(self, cursor):
self.cursor = cursor
- self.rows = []
self.initialized = False
def __iter__(self):
return self
def __next__(self):
- if self.rows:
- return self.rows.pop()
- else:
- self.initialized = True
- return next(self.cursor)
+ self.initialized = True
+ return next(self.cursor)
@property
def description(self):
"""Fetch first row to initialize cursor description when using server side cursor."""
if not self.initialized:
- element = self.cursor.fetchone()
- self.rows.append(element)
self.initialized = True
+ self.cursor.fetchone()
+ self.cursor.scroll(0, mode='absolute')
Review comment:
I like your current approach better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org