This repository was archived by the owner on Jul 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
#45 Add register_table/deregister_table and expose some public mod #46
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,33 @@ | ||
import pytest | ||
from datafusion import ExecutionContext | ||
import pyarrow as pa | ||
|
||
|
||
@pytest.fixture | ||
def ctx(): | ||
return ExecutionContext() | ||
|
||
|
||
@pytest.fixture | ||
def database(ctx, tmp_path): | ||
path = tmp_path / "test.csv" | ||
|
||
table = pa.Table.from_arrays( | ||
[ | ||
[1, 2, 3, 4], | ||
["a", "b", "c", "d"], | ||
[1.1, 2.2, 3.3, 4.4], | ||
], | ||
names=["int", "str", "float"], | ||
) | ||
pa.csv.write_csv(table, path) | ||
|
||
ctx.register_csv("csv", path) | ||
ctx.register_csv("csv1", str(path)) | ||
ctx.register_csv( | ||
"csv2", | ||
path, | ||
has_header=True, | ||
delimiter=",", | ||
schema_infer_max_records=10, | ||
) |
This file contains hidden or 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 |
---|---|---|
|
@@ -18,38 +18,6 @@ | |
import pyarrow as pa | ||
import pytest | ||
|
||
from datafusion import ExecutionContext | ||
|
||
|
||
@pytest.fixture | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to datafusion/tests/conftest.py for shared usage in |
||
def ctx(): | ||
return ExecutionContext() | ||
|
||
|
||
@pytest.fixture | ||
def database(ctx, tmp_path): | ||
path = tmp_path / "test.csv" | ||
|
||
table = pa.Table.from_arrays( | ||
[ | ||
[1, 2, 3, 4], | ||
["a", "b", "c", "d"], | ||
[1.1, 2.2, 3.3, 4.4], | ||
], | ||
names=["int", "str", "float"], | ||
) | ||
pa.csv.write_csv(table, path) | ||
|
||
ctx.register_csv("csv", path) | ||
ctx.register_csv("csv1", str(path)) | ||
ctx.register_csv( | ||
"csv2", | ||
path, | ||
has_header=True, | ||
delimiter=",", | ||
schema_infer_max_records=10, | ||
) | ||
|
||
|
||
def test_basic(ctx, database): | ||
with pytest.raises(KeyError): | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -38,7 +38,7 @@ pub(crate) struct PyDatabase { | |
} | ||
|
||
#[pyclass(name = "Table", module = "datafusion", subclass)] | ||
pub(crate) struct PyTable { | ||
pub struct PyTable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
table: Arc<dyn TableProvider>, | ||
} | ||
|
||
|
@@ -58,6 +58,10 @@ impl PyTable { | |
pub fn new(table: Arc<dyn TableProvider>) -> Self { | ||
Self { table } | ||
} | ||
|
||
pub fn table(&self) -> Arc<dyn TableProvider> { | ||
self.table.clone() | ||
} | ||
} | ||
|
||
#[pymethods] | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
|
@@ -25,7 +25,7 @@ use datafusion::physical_plan::functions::Volatility; | |
use crate::errors::DataFusionError; | ||
|
||
/// Utility to collect rust futures with GIL released | ||
pub(crate) fn wait_for_future<F: Future>(py: Python, f: F) -> F::Output | ||
pub fn wait_for_future<F: Future>(py: Python, f: F) -> F::Output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
where | ||
F: Send, | ||
F::Output: Send, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
want to reference in https://github.com/datafusion-contrib/datafusion-bigtable/pull/3/files#diff-775764fdcd55c2e241ba308b95a9f1f162d892a81ed83eab7d77fc2a0d09c948