tobixdev commented on code in PR #20312:
URL: https://github.com/apache/datafusion/pull/20312#discussion_r2987075066
##########
datafusion/expr/src/registry.rs:
##########
@@ -215,3 +218,281 @@ impl FunctionRegistry for MemoryFunctionRegistry {
self.udwfs.keys().cloned().collect()
}
}
+
+/// A cheaply cloneable pointer to an [ExtensionTypeRegistration].
+pub type ExtensionTypeRegistrationRef = Arc<dyn ExtensionTypeRegistration>;
+
+/// The registration of an extension type. Implementations of this trait are
responsible for
+/// *creating* instances of [`DFExtensionType`] that represent the entire
semantics of an extension
+/// type.
+///
+/// # Why do we need a Registration?
+///
+/// A good question is why this trait is even necessary. Why not directly
register the
+/// [`DFExtensionType`] in a registration?
+///
+/// While this works for extension types without parameters (e.g.,
`arrow.uuid`), it does not work
+/// for more complex extension types that may have another extension type as a
parameter. For
+/// example, consider an extension type `custom.shortened(n)` that aims to
short the pretty-printing
+/// string to `n` characters. Here, `n` is a parameter of the extension type
and should be a field
+/// in the concrete struct that implements the [`DFExtensionType`]. The job of
the registration is
+/// to read the metadata from the field and create the corresponding
[`DFExtensionType`] instance
+/// with the correct `n` set.
Review Comment:
I've not implemented this for now as I couln't find a good formulation that
does not introduce additional potential for confusion. Happy to add it if
someone is good with words.
--
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]