You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "waynexia (via GitHub)" <gi...@apache.org> on 2023/05/18 09:06:11 UTC

[GitHub] [arrow-datafusion] waynexia opened a new pull request, #6378: feat: implement serialize/deserialize for extension logical plan

waynexia opened a new pull request, #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes https://github.com/apache/arrow-datafusion/issues/6335.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Accomplish the serialize/deserialize part for logical plan extension.
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - A new field in `SessionState`: `ExtensionDeserializer`
   
     This is the registry (or dispatcher) of all extension's deserializer methods. In this PR only `UserDefinedLogicalPlan` is included.
   
   - Two new methods on `UserDefinedLogicalPlan`: `serialize` and `deserialize`
   
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   Yes
   
   # Are there any user-facing changes?
   
   Yes as described above. But both of them are non-breaking
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378#issuecomment-1553525804

   I plan to review this carefully tomorrow


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb merged pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] waynexia commented on pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378#issuecomment-1556647924

   >I wonder if we could simplify the interface by making no changes to UserDefinedLogicalNode and putting all serialization / deserialization code into ExtensionDeserializer? (maybe with a different name)
   
   Good suggestion 👍 This is the nasty part. I pushed a new commit [55c70b5](https://github.com/apache/arrow-datafusion/pull/6378/commits/55c70b5733c67ff390f3faedd1c4300b914f0091) that moves those methods into `SerializerRegistry` (which is the registry for all serialization and deserialization code). The deserialization part works like the previous, but it brings one more dispatch (the downcast) to serialization. I also considered only moving deserialization into registry and leaving the serializer in the `UserDefinedLogicalPlan` trait, however this also looks bad. I think I would go with the current `SerializerRegistry` one.
   
   About the naming, I use `SerializerRegistry` for now. Do you have other candidates? As the registry is not only for serialization, nor a real "dynamic registry"...


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] waynexia commented on a diff in pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "waynexia (via GitHub)" <gi...@apache.org>.
waynexia commented on code in PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378#discussion_r1199925668


##########
datafusion/core/src/execution/context.rs:
##########
@@ -2058,6 +2075,33 @@ fn create_dialect_from_str(dialect_name: &str) -> Result<Box<dyn Dialect>> {
     }
 }
 
+/// Deserializer registry for extensions like [UserDefinedLogicalNode].
+pub trait ExtensionDeserializer: Send + Sync {

Review Comment:
   Great reference, I'll move it there



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378#discussion_r1198950905


##########
datafusion/core/src/execution/context.rs:
##########
@@ -2058,6 +2075,33 @@ fn create_dialect_from_str(dialect_name: &str) -> Result<Box<dyn Dialect>> {
     }
 }
 
+/// Deserializer registry for extensions like [UserDefinedLogicalNode].
+pub trait ExtensionDeserializer: Send + Sync {

Review Comment:
   what do you think about putting this trait in `datafusion/execution/src/registry.rs` alongside 
   
   ```
   25: pub trait FunctionRegistry 
   ```
   
   Which serves a similar purpose for user defined functions?



##########
datafusion/expr/src/logical_plan/extension.rs:
##########
@@ -164,6 +164,26 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
     /// Note: [`UserDefinedLogicalNode`] is not constrained by [`Eq`]
     /// directly because it must remain object safe.
     fn dyn_eq(&self, other: &dyn UserDefinedLogicalNode) -> bool;
+
+    /// Serialize this node to a byte array. This serialization needs not to include

Review Comment:
   I think it might be clearer to say that the serialization *should not* include input plans (as they are serialized by the overall plan serializer, right?)



##########
datafusion/core/src/execution/context.rs:
##########
@@ -2058,6 +2075,33 @@ fn create_dialect_from_str(dialect_name: &str) -> Result<Box<dyn Dialect>> {
     }
 }
 
+/// Deserializer registry for extensions like [UserDefinedLogicalNode].
+pub trait ExtensionDeserializer: Send + Sync {
+    /// Deserialize user defined logical plan node ([UserDefinedLogicalNode]) from
+    /// bytes.
+    fn deserialize_logical_plan(
+        &self,
+        name: &str,
+        bytes: &[u8],
+    ) -> Result<Arc<dyn UserDefinedLogicalNode>>;
+}
+
+/// Default implementation of [ExtensionDeserializer] that throws unimplemented error

Review Comment:
   👍 



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6378: feat: implement serialize/deserialize for extension logical plan

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6378:
URL: https://github.com/apache/arrow-datafusion/pull/6378#discussion_r1200997303


##########
datafusion/core/src/execution/context.rs:
##########
@@ -1640,6 +1644,15 @@ impl SessionState {
         self
     }
 
+    /// Replace the extension deserializer

Review Comment:
   ```suggestion
       /// Replace the extension [`SerializerRegistry`]
   ```



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org