| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../generated/pyarrow.substrait.run_query.html | [Back] [Original] |
Section Navigation
Execute a Substrait plan and read the results as a RecordBatchReader.
Union[Buffer, bytes]The serialized Substrait plan to execute.
A function to resolve any NamedTable relation to a table. The function will receive two arguments which will be a list of strings representing the table name and a pyarrow.Schema representing the expected schema and should return a pyarrow.Table.
TrueIf True then multiple threads will be used to run the query. If False then all CPU intensive work will be done on the calling thread.
A reader containing the result of the executed query
Examples
>>> import pyarrow as pa
>>> from pyarrow.lib import tobytes
>>> import pyarrow.substrait as substrait
>>> test_table_1 = pa.Table.from_pydict({"x": [1, 2, 3]})
>>> test_table_2 = pa.Table.from_pydict({"x": [4, 5, 6]})
>>> def table_provider(names, schema):
... if not names:
... raise Exception("No names provided")
... elif names[0] == "t1":
... return test_table_1
... elif names[1] == "t2":
... return test_table_2
... else:
... raise Exception("Unrecognized table name")
...
>>> substrait_query = '''
... {
... "relations": [
... {"rel": {
... "read": {
... "base_schema": {
... "struct": {
... "types": [
... {"i64": {}}
... ]
... },
... "names": [
... "x"
... ]
... },
... "namedTable": {
... "names": ["t1"]
... }
... }
... }}
... ]
... }
... '''
>>> buf = pa._substrait._parse_json_plan(tobytes(substrait_query))
>>> reader = pa.substrait.run_query(buf, table_provider=table_provider)
>>> reader.read_all()
pyarrow.Table
x: int64
----
x: [[1,2,3]]
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |