Skip to content

Commit 787c5bc

Browse files
chore: Format examples in doc strings - datasource crates (#18338)
## Which issue does this PR close? Part of #16915 ## Rationale for this change Format code examples in documentation comments to improve readability and maintain consistent code style across the codebase. This is part of a multi-PR effort to format all doc comment examples and eventually enable CI checks to enforce this formatting. ## What changes are included in this PR? Run `cargo fmt -p <crate> -- --config format_code_in_doc_comments=true` for the following datasource-related crates: - `datafusion-datasource` - `datafusion-datasource-arrow` - `datafusion-datasource-avro` - `datafusion-datasource-csv` - `datafusion-datasource-json` - `datafusion-datasource-parquet` ## Are these changes tested? No testing needed - this is purely a formatting change with no functional modifications. ## Are there any user-facing changes? No - this only affects documentation formatting. --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
1 parent 4e0596d commit 787c5bc

File tree

7 files changed

+46
-47
lines changed

7 files changed

+46
-47
lines changed

datafusion/datasource-avro/src/avro_to_arrow/reader.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,9 @@ impl ReaderBuilder {
6464
/// let file = File::open("test/data/basic.avro").unwrap();
6565
///
6666
/// // create a builder, inferring the schema with the first 100 records
67-
/// let builder = ReaderBuilder::new()
68-
/// .read_schema()
69-
/// .with_batch_size(100);
67+
/// let builder = ReaderBuilder::new().read_schema().with_batch_size(100);
7068
///
71-
/// let reader = builder
72-
/// .build::<File>(file)
73-
/// .unwrap();
69+
/// let reader = builder.build::<File>(file).unwrap();
7470
///
7571
/// reader
7672
/// }

datafusion/datasource-parquet/src/page_filter.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ use parquet::{
9090
/// ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━━ ━━┛
9191
///
9292
/// Total rows: 300
93-
///
9493
/// ```
9594
///
9695
/// Given the predicate `A > 35 AND B = 'F'`:

datafusion/datasource-parquet/src/source.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ use parquet::encryption::decrypt::FileDecryptionProperties;
8585
/// │.───────────────────.│
8686
/// │ )
8787
/// `───────────────────'
88-
///
8988
/// ```
9089
///
9190
/// # Example: Create a `DataSourceExec`
@@ -349,7 +348,6 @@ impl ParquetSource {
349348
}
350349

351350
/// Optional user defined parquet file reader factory.
352-
///
353351
pub fn with_parquet_file_reader_factory(
354352
mut self,
355353
parquet_file_reader_factory: Arc<dyn ParquetFileReaderFactory>,

datafusion/datasource/src/file_scan_config.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,51 +1388,51 @@ fn create_output_array(
13881388
/// correctly sorted on `(A, B, C)`
13891389
///
13901390
/// ```text
1391-
///┏ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ┓
1392-
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ┐
1393-
///┃ ┌───────────────┐ ┌──────────────┐ │ ┌──────────────┐ │ ┌─────────────┐ ┃
1394-
/// │ │ 1.parquet │ │ │ │ 2.parquet │ │ │ 3.parquet │ │ │ 4.parquet │ │
1395-
///┃ │ Sort: A, B, C │ │Sort: A, B, C │ │ │Sort: A, B, C │ │ │Sort: A, B, C│ ┃
1396-
/// │ └───────────────┘ │ │ └──────────────┘ │ └──────────────┘ │ └─────────────┘ │
1397-
///┃ │ │ ┃
1398-
/// │ │ │ │ │ │
1399-
///┃ │ │ ┃
1400-
/// │ │ │ │ │ │
1401-
///┃ │ │ ┃
1402-
/// │ │ │ │ │ │
1403-
///┃ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃
1404-
/// DataFusion DataFusion DataFusion DataFusion
1405-
///┃ Partition 1 Partition 2 Partition 3 Partition 4 ┃
1406-
/// ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
1391+
/// ┏ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ┓
1392+
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ┐
1393+
/// ┃ ┌───────────────┐ ┌──────────────┐ │ ┌──────────────┐ │ ┌─────────────┐ ┃
1394+
/// │ │ 1.parquet │ │ │ │ 2.parquet │ │ │ 3.parquet │ │ │ 4.parquet │ │
1395+
/// ┃ │ Sort: A, B, C │ │Sort: A, B, C │ │ │Sort: A, B, C │ │ │Sort: A, B, C│ ┃
1396+
/// │ └───────────────┘ │ │ └──────────────┘ │ └──────────────┘ │ └─────────────┘ │
1397+
/// ┃ │ │ ┃
1398+
/// │ │ │ │ │ │
1399+
/// ┃ │ │ ┃
1400+
/// │ │ │ │ │ │
1401+
/// ┃ │ │ ┃
1402+
/// │ │ │ │ │ │
1403+
/// ┃ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃
1404+
/// DataFusion DataFusion DataFusion DataFusion
1405+
/// ┃ Partition 1 Partition 2 Partition 3 Partition 4 ┃
1406+
/// ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
14071407
///
14081408
/// DataSourceExec
1409-
///```
1409+
/// ```
14101410
///
14111411
/// However, when more than 1 file is assigned to each partition, each
14121412
/// partition is NOT correctly sorted on `(A, B, C)`. Once the second
14131413
/// file is scanned, the same values for A, B and C can be repeated in
14141414
/// the same sorted stream
14151415
///
14161416
///```text
1417-
///┏ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
1418-
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃
1419-
///┃ ┌───────────────┐ ┌──────────────┐ │
1420-
/// │ │ 1.parquet │ │ │ │ 2.parquet │ ┃
1421-
///┃ │ Sort: A, B, C │ │Sort: A, B, C │ │
1422-
/// │ └───────────────┘ │ │ └──────────────┘ ┃
1423-
///┃ ┌───────────────┐ ┌──────────────┐ │
1424-
/// │ │ 3.parquet │ │ │ │ 4.parquet │ ┃
1425-
///┃ │ Sort: A, B, C │ │Sort: A, B, C │ │
1426-
/// │ └───────────────┘ │ │ └──────────────┘ ┃
1427-
///┃ │
1428-
/// │ │ │ ┃
1429-
///┃ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
1430-
/// DataFusion DataFusion ┃
1431-
///┃ Partition 1 Partition 2
1432-
/// ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ┛
1417+
/// ┏ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━
1418+
/// ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┃
1419+
/// ┃ ┌───────────────┐ ┌──────────────┐ │
1420+
/// │ │ 1.parquet │ │ │ │ 2.parquet │ ┃
1421+
/// ┃ │ Sort: A, B, C │ │Sort: A, B, C │ │
1422+
/// │ └───────────────┘ │ │ └──────────────┘ ┃
1423+
/// ┃ ┌───────────────┐ ┌──────────────┐ │
1424+
/// │ │ 3.parquet │ │ │ │ 4.parquet │ ┃
1425+
/// ┃ │ Sort: A, B, C │ │Sort: A, B, C │ │
1426+
/// │ └───────────────┘ │ │ └──────────────┘ ┃
1427+
/// ┃ │
1428+
/// │ │ │ ┃
1429+
/// ┃ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘
1430+
/// DataFusion DataFusion ┃
1431+
/// ┃ Partition 1 Partition 2
1432+
/// ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ━ ┛
14331433
///
14341434
/// DataSourceExec
1435-
///```
1435+
/// ```
14361436
fn get_projected_output_ordering(
14371437
base_config: &FileScanConfig,
14381438
projected_schema: &SchemaRef,

datafusion/datasource/src/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ pub async fn calculate_range(
310310
/// Returns a `Result` wrapping a `usize` that represents the position of the first newline character found within the specified range. If no newline is found, it returns the length of the scanned data, effectively indicating the end of the range.
311311
///
312312
/// The function returns an `Error` if any issues arise while reading from the object store or processing the data stream.
313-
///
314313
async fn find_first_newline(
315314
object_store: &Arc<dyn ObjectStore>,
316315
location: &Path,

datafusion/datasource/src/url.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ const GLOB_START_CHARS: [char; 3] = ['?', '*', '['];
385385
///
386386
/// Path delimiters are determined using [`std::path::is_separator`] which
387387
/// permits `/` as a path delimiter even on Windows platforms.
388-
///
389388
#[cfg(not(target_arch = "wasm32"))]
390389
fn split_glob_expression(path: &str) -> Option<(&str, &str)> {
391390
let mut last_separator = 0;

datafusion/datasource/src/write/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ impl ObjectWriterBuilder {
162162
/// # let object_store = Arc::new(InMemory::new());
163163
/// let mut builder = ObjectWriterBuilder::new(compression_type, &location, object_store);
164164
/// builder.set_buffer_size(Some(20 * 1024 * 1024)); //20 MiB
165-
/// assert_eq!(builder.get_buffer_size(), Some(20 * 1024 * 1024), "Internal error: Builder buffer size doesn't match");
165+
/// assert_eq!(
166+
/// builder.get_buffer_size(),
167+
/// Some(20 * 1024 * 1024),
168+
/// "Internal error: Builder buffer size doesn't match"
169+
/// );
166170
/// ```
167171
pub fn set_buffer_size(&mut self, buffer_size: Option<usize>) {
168172
self.buffer_size = buffer_size;
@@ -182,7 +186,11 @@ impl ObjectWriterBuilder {
182186
/// # let object_store = Arc::new(InMemory::new());
183187
/// let builder = ObjectWriterBuilder::new(compression_type, &location, object_store)
184188
/// .with_buffer_size(Some(20 * 1024 * 1024)); //20 MiB
185-
/// assert_eq!(builder.get_buffer_size(), Some(20 * 1024 * 1024), "Internal error: Builder buffer size doesn't match");
189+
/// assert_eq!(
190+
/// builder.get_buffer_size(),
191+
/// Some(20 * 1024 * 1024),
192+
/// "Internal error: Builder buffer size doesn't match"
193+
/// );
186194
/// ```
187195
pub fn with_buffer_size(mut self, buffer_size: Option<usize>) -> Self {
188196
self.buffer_size = buffer_size;

0 commit comments

Comments
 (0)