Plans a sql and serializes the generated logical plan to bytes.
(sql: &str, ctx: &SessionContext)
| 52 | |
| 53 | /// Plans a sql and serializes the generated logical plan to bytes. |
| 54 | pub async fn serialize_bytes(sql: &str, ctx: &SessionContext) -> Result<Vec<u8>> { |
| 55 | let df = ctx.sql(sql).await?; |
| 56 | let plan = df.into_optimized_plan()?; |
| 57 | let proto = producer::to_substrait_plan(&plan, &ctx.state())?; |
| 58 | |
| 59 | let mut protobuf_out = Vec::<u8>::new(); |
| 60 | proto |
| 61 | .encode(&mut protobuf_out) |
| 62 | .map_err(|e| DataFusionError::Substrait(format!("Failed to encode plan: {e}")))?; |
| 63 | Ok(protobuf_out) |
| 64 | } |
| 65 | |
| 66 | /// Reads the file at `path` and deserializes a plan from the bytes. |
| 67 | pub async fn deserialize(path: impl AsRef<Path>) -> Result<Box<Plan>> { |
no test coverage detected
searching dependent graphs…