Skip to content

Commit 0ace196

Browse files
committed
Handle JSON raw-record options and bounded oversized diagnostics
1 parent 734ac63 commit 0ace196

3 files changed

Lines changed: 271 additions & 19 deletions

File tree

‎datafusion/datasource-json/src/file_format.rs‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use std::fmt::Debug;
2323
use std::io::{BufReader, Read};
2424
use std::sync::Arc;
2525

26+
pub use crate::recovery::RawJsonOptions;
2627
use crate::recovery::{JsonRecordHandler, JsonRecordHandlerFactory};
2728
use crate::source::JsonSource;
2829

@@ -153,6 +154,7 @@ impl Debug for JsonFormatFactory {
153154
pub struct JsonFormat {
154155
options: JsonOptions,
155156
raw_records: bool,
157+
raw_options: RawJsonOptions,
156158
record_handler: Option<Arc<dyn JsonRecordHandler>>,
157159
record_handler_factory: Option<Arc<dyn JsonRecordHandlerFactory>>,
158160
}
@@ -215,6 +217,12 @@ impl JsonFormat {
215217
self
216218
}
217219

220+
/// Configure byte-level handling for opt-in raw records.
221+
pub fn with_raw_record_options(mut self, options: RawJsonOptions) -> Self {
222+
self.raw_options = options;
223+
self
224+
}
225+
218226
/// Observe raw NDJSON records with one shared handler. Requires `with_raw_records(true)`.
219227
pub fn with_record_handler(mut self, handler: Arc<dyn JsonRecordHandler>) -> Self {
220228
self.record_handler = Some(handler);
@@ -409,7 +417,8 @@ impl FileFormat for JsonFormat {
409417
fn file_source(&self, table_schema: TableSchema) -> Arc<dyn FileSource> {
410418
let mut source = JsonSource::new(table_schema)
411419
.with_newline_delimited(self.options.newline_delimited)
412-
.with_raw_records(self.raw_records);
420+
.with_raw_records(self.raw_records)
421+
.with_raw_record_options(self.raw_options);
413422
if let Some(handler) = &self.record_handler {
414423
source = source.with_record_handler(Arc::clone(handler));
415424
} else if let Some(factory) = &self.record_handler_factory {

0 commit comments

Comments
 (0)