MCPcopy Create free account
hub / github.com/apache/datafusion / serialize_bytes

Function serialize_bytes

datafusion/substrait/src/serializer.rs:54–64  ·  view source on GitHub ↗

Plans a sql and serializes the generated logical plan to bytes.

(sql: &str, ctx: &SessionContext)

Source from the content-addressed store, hash-verified

52
53/// Plans a sql and serializes the generated logical plan to bytes.
54pub 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.
67pub async fn deserialize(path: impl AsRef<Path>) -> Result<Box<Plan>> {

Callers 1

serializeFunction · 0.85

Calls 6

to_substrait_planFunction · 0.85
newFunction · 0.85
sqlMethod · 0.80
into_optimized_planMethod · 0.80
encodeMethod · 0.80
stateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…