-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PyArrowDatasource that bypassed dataframe interchange protocol an…
…d supports Date32. Convert polars to pyarrow.
- Loading branch information
Showing
3 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .dfi_datasource import DfiDatasource | ||
from .pandas_datasource import PandasDatasource | ||
from .pyarrow_datasource import PyArrowDatasource | ||
from .datasource import Datasource |
16 changes: 16 additions & 0 deletions
16
python/vegafusion/vegafusion/datasource/pyarrow_datasource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from typing import Iterable | ||
import pyarrow as pa | ||
from .datasource import Datasource | ||
|
||
class PyArrowDatasource(Datasource): | ||
def __init__(self, dataframe: pa.Table): | ||
self._table = dataframe | ||
|
||
def schema(self) -> pa.Schema: | ||
return self._table.schema | ||
|
||
def fetch(self, columns: Iterable[str]) -> pa.Table: | ||
return pa.Table.from_arrays( | ||
[self._table[c] for c in columns], | ||
names=list(columns) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters