This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 7cbb4432ba minor: add builder setting 
`NdJsonReadOptions::schema_infer_max_records` (#18920)
7cbb4432ba is described below

commit 7cbb4432ba668e4b1822006de475711658682a38
Author: Jeffrey Vo <[email protected]>
AuthorDate: Wed Nov 26 06:48:10 2025 +1100

    minor: add builder setting `NdJsonReadOptions::schema_infer_max_records` 
(#18920)
    
    Noticed this was missing, meaning would have to do something awkward
    like:
    
    ```rust
        ctx.read_json(
            "/Users/jeffrey/Downloads/a.json",
            NdJsonReadOptions {
                schema_infer_max_records: 2,
                ..Default::default()
            },
        )
        .await?
        .show()
        .await?;
    ```
    
    Add this builder method to be consistent with the other options and be
    more ergonomic to use.
---
 datafusion/core/src/datasource/file_format/options.rs | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/datafusion/core/src/datasource/file_format/options.rs 
b/datafusion/core/src/datasource/file_format/options.rs
index e78c5f0955..6cca0d5033 100644
--- a/datafusion/core/src/datasource/file_format/options.rs
+++ b/datafusion/core/src/datasource/file_format/options.rs
@@ -523,6 +523,12 @@ impl<'a> NdJsonReadOptions<'a> {
         self.file_sort_order = file_sort_order;
         self
     }
+
+    /// Specify how many rows to read for schema inference
+    pub fn schema_infer_max_records(mut self, schema_infer_max_records: usize) 
-> Self {
+        self.schema_infer_max_records = schema_infer_max_records;
+        self
+    }
 }
 
 #[async_trait]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to