kumarUjjawal commented on code in PR #24187:
URL: https://github.com/apache/datafusion/pull/24187#discussion_r3741171656
##########
datafusion/proto/tests/cases/roundtrip_physical_plan.rs:
##########
@@ -3526,6 +3456,56 @@ async fn roundtrip_memory_source() -> Result<()> {
roundtrip_test(plan)
}
+#[tokio::test]
+async fn roundtrip_memory_source_sort_information_and_fetch() -> Result<()> {
+ use datafusion::datasource::memory::MemorySourceConfig;
+ use datafusion::datasource::source::DataSource as _;
+
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("a", DataType::Utf8, false),
+ Field::new("b", DataType::Int64, false),
+ ]));
+ let batch = RecordBatch::try_new(
+ Arc::clone(&schema),
+ vec![
+ Arc::new(arrow::array::StringArray::from(vec!["Tom", "Bob"])),
+ Arc::new(arrow::array::Int64Array::from(vec![18i64, 21i64])),
+ ],
+ )?;
+ let ordering = LexOrdering::new(vec![PhysicalSortExpr::new(
+ col("b", &schema)?,
+ SortOptions {
+ descending: true,
+ nulls_first: false,
+ },
+ )])
+ .unwrap();
+ let source = MemorySourceConfig::try_new(&[vec![batch]],
Arc::clone(&schema), None)?
+ .with_limit(Some(1))
+ .with_show_sizes(false)
+ .try_with_sort_information(vec![ordering])?;
+ let exec_plan = DataSourceExec::from_data_source(source);
+
+ let ctx = SessionContext::new();
+ let codec = DefaultPhysicalExtensionCodec {};
+ let proto_converter = DefaultPhysicalProtoConverter {};
+ let decoded = roundtrip_test_and_return(exec_plan, &ctx, &codec,
&proto_converter)?;
+
+ // The string representation does not include every field; check the
+ // decoded source directly.
+ let decoded = decoded
+ .downcast_ref::<DataSourceExec>()
+ .expect("expected DataSourceExec");
+ let decoded_source = decoded
+ .data_source()
+ .downcast_ref::<MemorySourceConfig>()
+ .expect("expected MemorySourceConfig");
+ assert_eq!(decoded_source.fetch(), Some(1));
+ assert!(!decoded_source.show_sizes());
+ assert_eq!(decoded_source.sort_information().len(), 1);
Review Comment:
Could this compare the decoded partitions, schema/projection, and complete
ordering rather than only the ordering count?
--
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]