tobixdev commented on code in PR #18552:
URL: https://github.com/apache/datafusion/pull/18552#discussion_r2613821133


##########
datafusion/core/tests/extension_types/pretty_print_data_frames.rs:
##########
@@ -0,0 +1,81 @@
+use arrow::array::{FixedSizeBinaryArray, RecordBatch};
+use arrow_schema::extension::Uuid;
+use arrow_schema::{DataType, Field, Schema, SchemaRef};
+use datafusion::dataframe::DataFrame;
+use datafusion::error::Result;
+use datafusion::prelude::SessionContext;
+use datafusion_common::metadata::FieldMetadata;
+use datafusion_common::ScalarValue;
+use datafusion_expr::{col, lit_with_metadata};
+use insta::assert_snapshot;
+use std::sync::Arc;
+
+fn test_schema() -> SchemaRef {
+    Arc::new(Schema::new(vec![uuid_field()]))
+}
+
+fn uuid_field() -> Field {
+    Field::new("my_uuids", DataType::FixedSizeBinary(16), 
false).with_extension_type(Uuid)
+}
+
+async fn create_test_table() -> Result<DataFrame> {
+    let schema = test_schema();
+
+    // define data.
+    let batch = RecordBatch::try_new(
+        schema,
+        vec![Arc::new(FixedSizeBinaryArray::from(vec![
+            &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
+            &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 5, 6],
+        ]))],
+    )?;
+
+    let ctx = SessionContext::new();
+
+    ctx.register_batch("test", batch)?;
+
+    ctx.table("test").await
+}
+
+#[tokio::test]
+async fn test_pretty_print_logical_plan() -> Result<()> {
+    let result = create_test_table().await?.to_string().await?;
+
+    assert_snapshot!(
+        result,
+        @r"
+    +--------------------------------------------------+

Review Comment:
   @paleolimbot FYI: Pretty-Printing record batches seems to work. So at least 
there's that 🥳.
   
   I am still working on integrating the pretty-printer into the logic plan as 
I am currently stretched on more urgent tasks. Once that's done, hopefully, 
this draft can help us in finding a conses on the architecture of extension 
types in DF.
   
   



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

Reply via email to