Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: migrate to sqlalchemy 2.0 #908

Merged
merged 11 commits into from
Jun 28, 2023
Merged
Prev Previous commit
Next Next commit
fix: migrate to sqlalchemy 2.0
gaurav274 committed Jun 26, 2023
commit 2593b4e3b6b7c90dd4dfe3046a348c519ebabbca
13 changes: 7 additions & 6 deletions evadb/storage/sqlite_storage_engine.py
Original file line number Diff line number Diff line change
@@ -59,14 +59,14 @@ def _dict_to_sql_row(self, dict_row: dict, columns: List[ColumnCatalogEntry]):
dict_row[col.name] = dict_row[col.name].tolist()
return dict_row

def _sql_row_to_dict(self, sql_row: tuple, columns: List[ColumnCatalogEntry]):
def _deserialize_sql_row(self, sql_row: dict, columns: List[ColumnCatalogEntry]):
# Deserialize numpy data
dict_row = {}
for idx, col in enumerate(columns):
if col.type == ColumnType.NDARRAY:
dict_row[col.name] = self._serializer.deserialize(sql_row[idx])
dict_row[col.name] = self._serializer.deserialize(sql_row[col.name])
else:
dict_row[col.name] = sql_row[idx]
dict_row[col.name] = sql_row[col.name]
return dict_row

def _try_loading_table_via_reflection(self, table_name: str):
@@ -177,14 +177,15 @@ def read(
"""
try:
table_to_read = self._try_loading_table_via_reflection(table.name)
result = self._sql_engine.execute(table_to_read.select())
result = self._sql_session.execute(table_to_read.select())
data_batch = []
row_size = None
for row in result:
# Todo: Verify the order of columns in row matches the table.columns
# For table read, we provide row_id so that user can also retrieve
# row_id from the table.
data_batch.append(self._sql_row_to_dict(row, table.columns))
data_batch.append(
self._deserialize_sql_row(row._asdict(), table.columns)
)
if row_size is None:
row_size = 0
row_size = get_size(data_batch)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ def read(path, encoding="utf-8"):
minimal_requirements = [
"numpy>=1.19.5",
"pandas>=1.1.5",
"sqlalchemy>=1.4.0,<2.0.0", # BREAKING CHANGES IN 2.0.0
"sqlalchemy>=2.0.0",
"sqlalchemy-utils>=0.36.6",
"lark>=1.0.0",
"pyyaml>=5.1",