tobixdev commented on code in PR #8829:
URL: https://github.com/apache/arrow-rs/pull/8829#discussion_r2520065872


##########
arrow-cast/src/pretty.rs:
##########
@@ -22,14 +22,99 @@
 //! [`RecordBatch`]: arrow_array::RecordBatch
 //! [`Array`]: arrow_array::Array
 
-use std::fmt::Display;
-
 use comfy_table::{Cell, Table};
+use std::fmt::{Display, Write};
+use std::sync::Arc;
 
-use arrow_array::{Array, ArrayRef, RecordBatch};
-use arrow_schema::{ArrowError, SchemaRef};
+use arrow_array::cast::AsArray;
+use arrow_array::{Array, ArrayRef, Int32Array, RecordBatch, array};
+use arrow_schema::{ArrowError, Field, SchemaRef};
 
-use crate::display::{ArrayFormatter, FormatOptions};
+use crate::display::{ArrayFormatter, DisplayIndex, FormatOptions};
+
+/// Allows creating a new [`ArrayFormatter`] for a given [`Array`] and an 
optional [`Field`].
+///
+/// # Example
+///
+/// The example below shows how to create a custom formatter for a custom type 
`my_money`.
+///
+/// ```rust
+/// use std::fmt::Write;
+/// use arrow_array::{Array, Int32Array, cast::AsArray};
+/// use arrow_cast::display::{ArrayFormatter, DisplayIndex, FormatOptions, 
FormatResult};
+/// use 
arrow_cast::pretty::{pretty_format_batches_with_options_and_formatters, 
ArrayFormatterFactory};
+/// use arrow_schema::{ArrowError, Field};
+///
+/// /// A custom formatter factory that can create a formatter for the special 
type `my_money`.
+/// ///
+/// /// This struct could have access to some kind of extension type registry 
that can lookup the
+/// /// correct formatter for an extension type on-demand.
+/// struct MyFormatters {}
+///
+/// impl ArrayFormatterFactory for MyFormatters {

Review Comment:
   From the DataFusion perspective, this would be the trait that we would 
implenent. It looks up any existing extension types in the registry and uses 
the custom printing implementation.



-- 
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]

Reply via email to