killzoner commented on code in PR #1420:
URL:
https://github.com/apache/datafusion-ballista/pull/1420#discussion_r2821158685
##########
ballista/core/src/serde/mod.rs:
##########
@@ -186,17 +191,63 @@ impl LogicalExtensionCodec for
BallistaLogicalExtensionCodec {
&self,
buf: &[u8],
inputs: &[datafusion::logical_expr::LogicalPlan],
- ctx: &TaskContext,
+ _ctx: &TaskContext,
) -> Result<datafusion::logical_expr::Extension> {
- self.default_codec.try_decode(buf, inputs, ctx)
+ let plan: protobuf::BallistaLogicalPlanNode =
+ protobuf::BallistaLogicalPlanNode::decode(buf).map_err(|e| {
+ DataFusionError::Internal(format!(
+ "Could not deserialize BallistaLogicalPlanNode: {e}"
+ ))
+ })?;
+
+ let plan: protobuf::ballista_logical_plan_node::LogicalPlanType =
+ plan.logical_plan_type.ok_or_else(|| {
+ DataFusionError::Internal(
+ "Could not deserialize BallistaLogicalPlanNode because
it's logical_plan_type is none".to_string()
+ )
+ })?;
+
+ match plan {
+ LogicalPlanType::CacheNode(plan_cache) => Ok(Extension {
+ node: Arc::new(BallistaCacheNode::new(
+ plan_cache.cache_id,
+ plan_cache.session_id,
+ inputs
+ .first()
+ .ok_or(DataFusionError::Plan(
+ "expected input size of 1".to_string(),
+ ))?
+ .clone(),
+ )),
+ }),
+ }
}
fn try_encode(
&self,
node: &datafusion::logical_expr::Extension,
buf: &mut Vec<u8>,
) -> Result<()> {
- self.default_codec.try_encode(node, buf)
+ if let Some(node) =
node.node.as_any().downcast_ref::<BallistaCacheNode>() {
+ let proto = protobuf::BallistaLogicalPlanNode {
+ logical_plan_type: Some(LogicalPlanType::CacheNode(
+ protobuf::LogicalPlanCacheNode {
+ cache_id: node.cache_id().to_owned(),
+ session_id: node.session_id().to_owned(),
+ },
+ )),
+ };
+
+ proto.encode(buf).map_err(|e| {
+ DataFusionError::Internal(format!(
+ "failed to encode cache node logical plan: {e:?}"
+ ))
+ })?;
+
+ Ok(())
+ } else {
+ Ok(())
Review Comment:
this should be `self.default_codec.try_encode(node, buf)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]