Skip to content

Commit 3469be4

Browse files
committed
fix: Force reading longer batch if type inference failed
1 parent 60078b2 commit 3469be4

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

cosmotech/coal/cli/commands/store/dump_to_postgresql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from time import perf_counter
99

1010
from adbc_driver_postgresql import dbapi
11+
import pyarrow as pa
1112

1213
from cosmotech.coal.cli.utils.click import click
1314
from cosmotech.coal.cli.utils.decorators import web_help

cosmotech/coal/store/store.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,17 @@ def add_table(self, table_name: str, data=pyarrow.Table, replace: bool = False):
5252
LOGGER.debug(f"Inserted {rows} rows in table {table_name}")
5353

5454
def execute_query(self, sql_query: str) -> pyarrow.Table:
55-
with dbapi.connect(self._database, autocommit=True) as conn:
56-
with conn.cursor() as curs:
57-
curs.execute(sql_query)
58-
return curs.fetch_arrow_table()
55+
batch_size = 1024
56+
batch_size_increment = 1024
57+
while True:
58+
try:
59+
with dbapi.connect(self._database, autocommit=True) as conn:
60+
with conn.cursor() as curs:
61+
curs.adbc_statement.set_options(**{"adbc.sqlite.query.batch_rows":str(batch_size)})
62+
curs.execute(sql_query)
63+
return curs.fetch_arrow_table()
64+
except OSError:
65+
batch_size += batch_size_increment
5966

6067
def list_tables(self) -> list[str]:
6168
with dbapi.connect(self._database) as conn:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ azure-kusto-ingest~=4.4.1
77
tenacity~=8.3.0
88

99
# Keycloak connection
10-
python-keycloak~=4.3.0
10+
python-keycloak~=4.7.3
1111

1212
# Modelops requirements
1313
redis==4.4.4

0 commit comments

Comments
 (0)