Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefffrey committed May 12, 2024
1 parent ab24080 commit b5c6c80
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/datafusion/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
//! Integration with [Apache DataFusion](https://datafusion.apache.org/) query engine to
//! allow querying ORC files with a SQL/DataFrame API.
//!
//! # Example usage
//!
//! ```no_run
//! # use datafusion::prelude::*;
//! # use datafusion::error::Result;
//! # use orc_rust::datafusion::{OrcReadOptions, SessionContextOrcExt};
//! # #[tokio::main]
//! # async fn main() -> Result<()> {
//! let ctx = SessionContext::new();
//! ctx.register_orc(
//! "table1",
//! "/path/to/file.orc",
//! OrcReadOptions::default(),
//! )
//! .await?;
//!
//! ctx.sql("select a, b from table1")
//! .await?
//! .show()
//! .await?;
//! # Ok(())
//! # }
//! ```

use std::sync::Arc;

use datafusion::arrow::datatypes::SchemaRef;
Expand All @@ -22,6 +49,7 @@ mod file_format;
mod object_store_reader;
mod physical_exec;

/// Configuration options for reading ORC files.
#[derive(Clone)]
pub struct OrcReadOptions<'a> {
pub file_extension: &'a str,
Expand Down Expand Up @@ -57,6 +85,8 @@ impl ReadOptions<'_> for OrcReadOptions<'_> {
}
}

/// Exposes new functions for registering ORC tables onto a DataFusion [`SessionContext`]
/// to enable querying them using the SQL or DataFrame API.
pub trait SessionContextOrcExt {
fn read_orc<P: DataFilePaths + Send>(
&self,
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
//! let reader = ArrowReaderBuilder::try_new(file).unwrap().build();
//! let record_batches = reader.collect::<Result<Vec<_>, _>>().unwrap();
//! ```
//!
//! See the [`datafusion`] module for information on how to integrate with
//! [Apache DataFusion](https://datafusion.apache.org/).

pub mod arrow_reader;
#[cfg(feature = "async")]
Expand Down
2 changes: 1 addition & 1 deletion src/reader/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! File tail structure:
//!
//! ```
//! ```text
//! ------------------
//! | Metadata |
//! | |
Expand Down

0 comments on commit b5c6c80

Please sign in to comment.