| 240 | |
| 241 | |
| 242 | def test_named_table_invalid_table_name(): |
| 243 | test_table_1 = pa.Table.from_pydict({"x": [1, 2, 3]}) |
| 244 | |
| 245 | def table_provider(names, _): |
| 246 | if not names: |
| 247 | raise Exception("No names provided") |
| 248 | elif names[0] == "t1": |
| 249 | return test_table_1 |
| 250 | else: |
| 251 | raise Exception("Unrecognized table name") |
| 252 | |
| 253 | substrait_query = """ |
| 254 | { |
| 255 | "version": { "major": 9999 }, |
| 256 | "relations": [ |
| 257 | {"rel": { |
| 258 | "read": { |
| 259 | "base_schema": { |
| 260 | "struct": { |
| 261 | "types": [ |
| 262 | {"i64": {}} |
| 263 | ] |
| 264 | }, |
| 265 | "names": [ |
| 266 | "x" |
| 267 | ] |
| 268 | }, |
| 269 | "namedTable": { |
| 270 | "names": ["t3"] |
| 271 | } |
| 272 | } |
| 273 | }} |
| 274 | ] |
| 275 | } |
| 276 | """ |
| 277 | |
| 278 | buf = pa._substrait._parse_json_plan(tobytes(substrait_query)) |
| 279 | exec_message = "Invalid NamedTable Source" |
| 280 | with pytest.raises(ArrowInvalid, match=exec_message): |
| 281 | substrait.run_query(buf, table_provider=table_provider) |
| 282 | |
| 283 | |
| 284 | def test_named_table_empty_names(): |