kazanzhy commented on a change in pull request #21307:
URL: https://github.com/apache/airflow/pull/21307#discussion_r799663382
##########
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:
Sorry for the misleading.
First of all server-side cursor doesn't support `relative` mode by default.
It should be initialized like `conn.cursor(name='...', scrollable=True)`. But
absolute mode could be used.
But both scrolls cause a reset of `.description` attribute. So,
unfortunately, they could not be used.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]