Skip to content

Commit

Permalink
add dremio native implementation for full frames and tables
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-rp committed Aug 7, 2024
1 parent 6f6500f commit 152b788
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
17 changes: 15 additions & 2 deletions dlt/destinations/impl/databricks/sql_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
from contextlib import contextmanager, suppress
from typing import Any, AnyStr, ClassVar, Generator, Iterator, Optional, Sequence, List, Tuple, Union, Dict
from typing import (
Any,
AnyStr,
ClassVar,
Generator,
Iterator,
Optional,
Sequence,
List,
Tuple,
Union,
Dict,
)


from databricks import sql as databricks_lib
Expand Down Expand Up @@ -44,7 +56,8 @@ def iter_arrow(self, chunk_size: int) -> Generator[ArrowTable, None, None]:
def iter_df(self, chunk_size: int) -> Generator[DataFrame, None, None]:
for table in self.iter_arrow(chunk_size=chunk_size):
yield table.to_pandas()



class DatabricksSqlClient(SqlClientBase[DatabricksSqlConnection], DBTransaction):
dbapi: ClassVar[DBApi] = databricks_lib

Expand Down
7 changes: 6 additions & 1 deletion dlt/destinations/impl/dremio/sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ class DremioCursorImpl(DBApiCursorImpl):

def df(self, chunk_size: int = None, **kwargs: Any) -> Optional[DataFrame]:
if chunk_size is None:
return self.native_cursor.fetch_arrow_table().to_pandas()
return self.arrow(chunk_size=chunk_size).to_pandas()
return super().df(chunk_size=chunk_size, **kwargs)

def arrow(self, chunk_size: int = None, **kwargs: Any) -> Optional[DataFrame]:
if chunk_size is None:
return self.native_cursor.fetch_arrow_table()
return super().arrow(chunk_size=chunk_size, **kwargs)


class DremioSqlClient(SqlClientBase[pydremio.DremioConnection]):
dbapi: ClassVar[DBApi] = pydremio
Expand Down

0 comments on commit 152b788

Please sign in to comment.