-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bad-rebase): fixed typos and added test
I had to re-add FromSubstraitFunctionData, so in the process I forgot to return unique_ptr<FunctionData> instead. Also re-added missing closing brace. This also adds a test, but I haven't been able to actually test it. Additionally, it seems that calling explain is truncating the result, so I need to figure out how to prevent that from happening in order to create a proper expected output (and to make the function itself useful).
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 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
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,26 @@ | ||
import pandas as pd | ||
import duckdb | ||
|
||
EXPECTED_RESULT = ''' | ||
┌───────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────┐ | ||
│ explain_key │ explain_value │ | ||
│ varchar │ varchar │ | ||
├───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────┤ | ||
│ physical_plan │ ┌───────────────────────────┐\n│ STREAMING_LIMIT │\n└─────────────┬─────────────┘\n┌────… │ | ||
└───────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────┘ | ||
''' | ||
|
||
def test_roundtrip_substrait(require): | ||
connection = require('substrait') | ||
connection.execute('CREATE TABLE integers (i integer)') | ||
connection.execute('INSERT INTO integers VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(NULL)') | ||
|
||
translate_result = connection.get_substrait('SELECT * FROM integers LIMIT 5') | ||
proto_bytes = translate_result.fetchone()[0] | ||
|
||
expected = pd.Series([EXPECTED_RESULT], name='Explain Plan', dtype='str') | ||
actual = connection.table_function('explain_substrait', proto_bytes).execute() | ||
|
||
pd.testing.assert_series_equal(actual.df()['Explain Plan'], expected) | ||
|