Plans a sql and serializes the generated logical plan to bytes. The bytes are then written into a file at `path`. Returns an error if the file already exists.
(
sql: &str,
ctx: &SessionContext,
path: impl AsRef<Path>,
)
| 34 | /// |
| 35 | /// Returns an error if the file already exists. |
| 36 | pub async fn serialize( |
| 37 | sql: &str, |
| 38 | ctx: &SessionContext, |
| 39 | path: impl AsRef<Path>, |
| 40 | ) -> Result<()> { |
| 41 | let protobuf_out = serialize_bytes(sql, ctx).await?; |
| 42 | |
| 43 | let mut file = OpenOptions::new() |
| 44 | .write(true) |
| 45 | .create_new(true) |
| 46 | .open(path) |
| 47 | .await?; |
| 48 | file.write_all(&protobuf_out).await?; |
| 49 | file.flush().await?; |
| 50 | Ok(()) |
| 51 | } |
| 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>> { |