MCPcopy Create free account
hub / github.com/apache/arrow / test_named_table

Function test_named_table

python/pyarrow/tests/test_substrait.py:194–239  ·  view source on GitHub ↗
(use_threads)

Source from the content-addressed store, hash-verified

192
193@pytest.mark.parametrize("use_threads", [True, False])
194def test_named_table(use_threads):
195 test_table_1 = pa.Table.from_pydict({"x": [1, 2, 3]})
196 test_table_2 = pa.Table.from_pydict({"x": [4, 5, 6]})
197 schema_1 = pa.schema([pa.field("x", pa.int64())])
198
199 def table_provider(names, schema):
200 if not names:
201 raise Exception("No names provided")
202 elif names[0] == "t1":
203 assert schema == schema_1
204 return test_table_1
205 elif names[1] == "t2":
206 return test_table_2
207 else:
208 raise Exception("Unrecognized table name")
209
210 substrait_query = """
211 {
212 "version": { "major": 9999 },
213 "relations": [
214 {"rel": {
215 "read": {
216 "base_schema": {
217 "struct": {
218 "types": [
219 {"i64": {}}
220 ]
221 },
222 "names": [
223 "x"
224 ]
225 },
226 "namedTable": {
227 "names": ["t1"]
228 }
229 }
230 }}
231 ]
232 }
233 """
234
235 buf = pa._substrait._parse_json_plan(tobytes(substrait_query))
236 reader = pa.substrait.run_query(
237 buf, table_provider=table_provider, use_threads=use_threads)
238 res_tb = reader.read_all()
239 assert res_tb == test_table_1
240
241
242def test_named_table_invalid_table_name():

Callers

nothing calls this directly

Calls 3

tobytesFunction · 0.85
schemaMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected