DoumanAsh commented on code in PR #19262:
URL: https://github.com/apache/datafusion/pull/19262#discussion_r2613695133
##########
datafusion/core/tests/dataframe/mod.rs:
##########
@@ -6735,3 +6735,70 @@ async fn
test_duplicate_state_fields_for_dfschema_construct() -> Result<()> {
Ok(())
}
+
+#[tokio::test]
+async fn write_partitioned_parquet_results_with_prefix() -> Result<()> {
+ // create partitioned input file and context
+ let tmp_dir = TempDir::new()?;
+
+ let mut config = SessionConfig::new();
+ config.options_mut().execution.partitioned_file_prefix_name =
"prefix".to_owned();
+ let ctx = SessionContext::new_with_config(config);
+
+ // Create an in memory table with schema C1 and C2, both strings
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("c1", DataType::Utf8, false),
+ Field::new("c2", DataType::Utf8, false),
+ ]));
+
+ let record_batch = RecordBatch::try_new(
+ schema.clone(),
+ vec![
+ Arc::new(StringArray::from(vec!["abc", "def"])),
+ Arc::new(StringArray::from(vec!["123", "456"])),
+ ],
+ )?;
+
+ let mem_table = Arc::new(MemTable::try_new(schema,
vec![vec![record_batch]])?);
+
+ // Register the table in the context
+ ctx.register_table("test", mem_table)?;
+
+ let local = Arc::new(LocalFileSystem::new_with_prefix(&tmp_dir)?);
+ let local_url = Url::parse("file://local").unwrap();
+ ctx.register_object_store(&local_url, local);
+
+ // execute a simple query and write the results to parquet
+ let out_dir = tmp_dir.as_ref().to_str().unwrap().to_string() + "/out/";
+ let out_dir_url = format!("file://{out_dir}");
+
+ // Write the results to parquet with partitioning
+ let df = ctx.sql("SELECT c1, c2 FROM test").await?;
+ let df_write_options =
+
DataFrameWriteOptions::new().with_partition_by(vec![String::from("c2")]);
Review Comment:
I modified test code to include all possible scenarios:
- Write partitioned output
- Write chunked output
- Write physical plan via datasource-*
--
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]