| 1058 | |
| 1059 | |
| 1060 | def test_serializing_udfs(): |
| 1061 | # Note, UDF in this context means a function that is not |
| 1062 | # recognized by Substrait. It might still be a builtin pyarrow |
| 1063 | # function. |
| 1064 | schema = pa.schema([ |
| 1065 | pa.field("x", pa.uint32()) |
| 1066 | ]) |
| 1067 | a = pc.scalar(10) |
| 1068 | b = pc.scalar(4) |
| 1069 | exprs = [pc.shift_left(a, b)] |
| 1070 | |
| 1071 | with pytest.raises(ArrowNotImplementedError): |
| 1072 | pa.substrait.serialize_expressions(exprs, ["expr"], schema) |
| 1073 | |
| 1074 | buf = pa.substrait.serialize_expressions( |
| 1075 | exprs, ["expr"], schema, allow_arrow_extensions=True) |
| 1076 | returned = pa.substrait.deserialize_expressions(buf) |
| 1077 | assert schema == returned.schema |
| 1078 | assert len(returned.expressions) == 1 |
| 1079 | assert str(returned.expressions["expr"]) == str(exprs[0]) |
| 1080 | |
| 1081 | |
| 1082 | def test_serializing_schema(): |