Apache DataFusion SQL Query Engine
Minor: Fix doc links and typos (#5225)
Jeffreyeda875bfb579
diff --git a/datafusion/common/src/config.rs b/datafusion/common/src/config.rsindex 6ce3f64eeb..6033d4a0cc 100644--- a/datafusion/common/src/config.rs+++ b/datafusion/common/src/config.rs@@ -181,10 +181,10 @@ config_namespace! {config_namespace! {/// Options related to SQL parserpub struct SqlParserOptions {- /// When set to true, sql parser will parse float as decimal type+ /// When set to true, SQL parser will parse float as decimal typepub parse_float_as_decimal: bool, default = false- /// When set to true, sql parser will normalize ident(convert ident to lowercase when not quoted)+ /// When set to true, SQL parser will normalize ident (convert ident to lowercase when not quoted)pub enable_ident_normalization: bool, default = true}@@ -194,7 +194,7 @@ config_namespace! {/// Options related to query executionpub struct ExecutionOptions {/// Default batch size while creating new batches, it's especially useful for- /// buffer-in-memory batches since creating tiny batches would results in too much+ /// buffer-in-memory batches since creating tiny batches would result in too much/// metadata memory consumptionpub batch_size: usize, default = 8192@@ -208,12 +208,12 @@ config_namespace! {pub collect_statistics: bool, default = false/// Number of partitions for query execution. Increasing partitions can increase- /// concurrency. Defaults to the number of cpu cores on the system+ /// concurrency. Defaults to the number of CPU cores on the systempub target_partitions: usize, default = num_cpus::get()/// The default time zone///- /// Some functions, e.g. EXTRACT(HOUR from SOME_TIME), shift the underlying datetime+ /// Some functions, e.g. `EXTRACT(HOUR from SOME_TIME)`, shift the underlying datetime/// according to this time zone, and then extract the hourpub time_zone: Option<String>, default = Some("+00:00".into())@@ -240,7 +240,7 @@ config_namespace! {pub skip_metadata: bool, default = true/// If specified, the parquet reader will try and fetch the last `size_hint`- /// bytes of the parquet file optimistically. If not specified, two read are required:+ /// bytes of the parquet file optimistically. If not specified, two reads are required:/// One read to fetch the 8-byte parquet footer and/// another to fetch the metadata length encoded in the footerpub metadata_size_hint: Option<usize>, default = None@@ -260,7 +260,7 @@ config_namespace! {/// Options related to query optimizationpub struct OptimizerOptions {/// When set to true, the physical plan optimizer will try to add round robin- /// repartition to increase parallelism to leverage more CPU cores+ /// repartitioning to increase parallelism to leverage more CPU corespub enable_round_robin_repartition: bool, default = true/// When set to true, the optimizer will insert filters before a join between@@ -270,14 +270,14 @@ config_namespace! {pub filter_null_join_keys: bool, default = false/// Should DataFusion repartition data using the aggregate keys to execute aggregates- /// in parallel using the provided `target_partitions` level"+ /// in parallel using the provided `target_partitions` levelpub repartition_aggregations: bool, default = true/// Minimum total files size in bytes to perform file scan repartitioning.pub repartition_file_min_size: usize, default = 10 * 1024 * 1024/// Should DataFusion repartition data using the join keys to execute joins in parallel- /// using the provided `target_partitions` level"+ /// using the provided `target_partitions` levelpub repartition_joins: bool, default = true/// When set to true, file groups will be repartitioned to achieve maximum parallelism.@@ -287,11 +287,11 @@ config_namespace! {pub repartition_file_scans: bool, default = false/// Should DataFusion repartition data using the partitions keys to execute window- /// functions in parallel using the provided `target_partitions` level"+ /// functions in parallel using the provided `target_partitions` levelpub repartition_windows: bool, default = true/// Should DataFusion execute sorts in a per-partition fashion and merge- /// afterwards instead of coalescing first and sorting globally+ /// afterwards instead of coalescing first and sorting globally./// With this flag is enabled, plans in the form below/// "SortExec: [a@0 ASC]",/// " CoalescePartitionsExec",diff --git a/datafusion/core/src/datasource/file_format/mod.rs b/datafusion/core/src/datasource/file_format/mod.rsindex f49db0b20b..e753364a55 100644--- a/datafusion/core/src/datasource/file_format/mod.rs+++ b/datafusion/core/src/datasource/file_format/mod.rs@@ -17,7 +17,7 @@//! Module containing helper methods for the various file formats-/// default max records to scan to infer the schema+/// Default max records to scan to infer the schemapub const DEFAULT_SCHEMA_INFER_MAX_RECORD: usize = 1000;pub mod avro;@@ -41,8 +41,10 @@ use async_trait::async_trait;use object_store::{ObjectMeta, ObjectStore};/// This trait abstracts all the file format specific implementations-/// from the `TableProvider`. This helps code re-utilization across+/// from the [`TableProvider`]. This helps code re-utilization across/// providers that support the the same file formats.+///+/// [`TableProvider`]: crate::datasource::datasource::TableProvider#[async_trait]pub trait FileFormat: Send + Sync + fmt::Debug {/// Returns the table provider as [`Any`](std::any::Any) so that it can bediff --git a/datafusion/core/src/datasource/file_format/parquet.rs b/datafusion/core/src/datasource/file_format/parquet.rsindex 0d577cecfe..0c5c324d00 100644--- a/datafusion/core/src/datasource/file_format/parquet.rs+++ b/datafusion/core/src/datasource/file_format/parquet.rs@@ -61,28 +61,28 @@ pub const DEFAULT_PARQUET_EXTENSION: &str = ".parquet";/// <https://github.com/apache/arrow-datafusion/issues/4349>#[derive(Debug, Default)]pub struct ParquetFormat {- /// Override the global setting for enable_pruning+ /// Override the global setting for `enable_pruning`enable_pruning: Option<bool>,- /// Override the global setting for metadata_size_hint+ /// Override the global setting for `metadata_size_hint`metadata_size_hint: Option<usize>,- /// Override the global setting for skip_metadata+ /// Override the global setting for `skip_metadata`skip_metadata: Option<bool>,}impl ParquetFormat {- /// construct a new Format with no local overrides+ /// Construct a new Format with no local overridespub fn new() -> Self {Self::default()}/// Activate statistics based row group level pruning- /// - If None, defaults to value on `config_options`+ /// - If `None`, defaults to value on `config_options`pub fn with_enable_pruning(mut self, enable: Option<bool>) -> Self {self.enable_pruning = enable;self}- /// Return true if pruning is enabled+ /// Return `true` if pruning is enabledpub fn enable_pruning(&self, config_options: &ConfigOptions) -> bool {self.enable_pruning.unwrap_or(config_options.execution.parquet.pruning)@@ -90,10 +90,10 @@ impl ParquetFormat {/// Provide a hint to the size of the file metadata. If a hint is provided/// the reader will try and fetch the last `size_hint` bytes of the parquet file optimistically.- /// With out a hint, two read are required. One read to fetch the 8-byte parquet footer and then+ /// Without a hint, two read are required. One read to fetch the 8-byte parquet footer and then/// another read to fetch the metadata length encoded in the footer.///- /// - If None, defaults to value on `config_options`+ /// - If `None`, defaults to value on `config_options`pub fn with_metadata_size_hint(mut self, size_hint: Option<usize>) -> Self {self.metadata_size_hint = size_hint;self@@ -109,13 +109,13 @@ impl ParquetFormat {/// the file Schema. This can help avoid schema conflicts due to/// metadata.///- /// - If None, defaults to value on `config_options`+ /// - If `None`, defaults to value on `config_options`pub fn with_skip_metadata(mut self, skip_metadata: Option<bool>) -> Self {self.skip_metadata = skip_metadata;self}- /// returns true if schema metadata will be cleared prior to+ /// Returns `true` if schema metadata will be cleared prior to/// schema merging.pub fn skip_metadata(&self, config_options: &ConfigOptions) -> bool {self.skip_metadata@@ -375,7 +375,9 @@ fn summarize_min_max(/// Fetches parquet metadata from ObjectStore for given object////// This component is a subject to **change** in near future and is exposed for low level integrations-/// through [ParquetFileReaderFactory].+/// through [`ParquetFileReaderFactory`].+///+/// [`ParquetFileReaderFactory`]: crate::physical_plan::file_format::ParquetFileReaderFactorypub async fn fetch_parquet_metadata(store: &dyn ObjectStore,meta: &ObjectMeta,diff --git a/datafusion/core/src/datasource/memory.rs b/datafusion/core/src/datasource/memory.rsindex 38588fd870..ac1f4947f8 100644--- a/datafusion/core/src/datasource/memory.rs+++ b/datafusion/core/src/datasource/memory.rs@@ -15,7 +15,7 @@// specific language governing permissions and limitations// under the License.-//! In-memory data source for presenting a Vec<RecordBatch> as a data source that can be+//! In-memory data source for presenting a `Vec<RecordBatch>` as a data source that can be//! queried by DataFusion. This allows data to be pre-loaded into memory and then//! repeatedly queried without incurring additional file I/O overhead.diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rsindex a053f640fb..0873895f79 100644--- a/datafusion/core/src/execution/context.rs+++ b/datafusion/core/src/execution/context.rs@@ -149,7 +149,7 @@ use super::options::{/// ```#[derive(Clone)]pub struct SessionContext {- /// Uuid for the session+ /// UUID for the sessionsession_id: String,/// Session start timesession_start_time: DateTime<Utc>,@@ -169,7 +169,7 @@ impl SessionContext {Self::with_config(SessionConfig::new())}- /// Finds any ListSchemaProviders and instructs them to reload tables from "disk"+ /// Finds any [`ListingSchemaProvider`]s and instructs them to reload tables from "disk"pub async fn refresh_catalogs(&self) -> Result<()> {let cat_names = self.catalog_names().clone();for cat_name in cat_names.iter() {@@ -195,7 +195,7 @@ impl SessionContext {Self::with_config_rt(config, runtime)}- /// Creates a new session context using the provided configuration and RuntimeEnv.+ /// Creates a new session context using the provided configuration and [`RuntimeEnv`].pub fn with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self {let state = SessionState::with_config_rt(config, runtime);Self::with_state(state)@@ -235,12 +235,12 @@ impl SessionContext {self.state.read().runtime_env.clone()}- /// Return the session_id of this Session+ /// Return the `session_id` of this Sessionpub fn session_id(&self) -> String {self.session_id.clone()}- /// Return the enable_ident_normalization of this Session+ /// Return the `enable_ident_normalization` of this Sessionpub fn enable_ident_normalization(&self) -> bool {self.state.read()@@ -257,7 +257,7 @@ impl SessionContext {/// Creates a [`DataFrame`] that will execute a SQL query.///- /// Note: This api implements DDL such as `CREATE TABLE` and `CREATE VIEW` with in memory+ /// Note: This API implements DDL such as `CREATE TABLE` and `CREATE VIEW` with in-memory/// default implementations.////// If this is not desirable, consider using [`SessionState::create_logical_plan()`] which@@ -661,7 +661,7 @@ impl SessionContext {self._read_type(table_path, options).await}- /// Creates a [`DataFrame`] for reading an Json data source.+ /// Creates a [`DataFrame`] for reading an JSON data source.////// For more control such as reading multiple files, you can use/// [`read_table`](Self::read_table) with a [`ListingTable`].@@ -788,7 +788,7 @@ impl SessionContext {Ok(())}- /// Registers a Json file as a table that it can be referenced+ /// Registers a JSON file as a table that it can be referenced/// from SQL statements executed against this context.pub async fn register_json(&self,@@ -906,7 +906,7 @@ impl SessionContext {.deregister_table(&table)}- /// Return true if the specified table exists in the schema provider.+ /// Return `true` if the specified table exists in the schema provider.pub fn table_exist<'a>(&'a self,table_ref: impl Into<TableReference<'a>>,@@ -1105,8 +1105,8 @@ type AnyMap =/// Hasher for [`AnyMap`].///-/// With [`TypeId`}s as keys, there's no need to hash them. They are already hashes themselves, coming from the compiler.-/// The [`IdHasher`} just holds the [`u64`} of the [`TypeId`}, and then returns it, instead of doing any bit fiddling.+/// With [`TypeId`]s as keys, there's no need to hash them. They are already hashes themselves, coming from the compiler.+/// The [`IdHasher`] just holds the [`u64`] of the [`TypeId`], and then returns it, instead of doing any bit fiddling.#[derive(Default)]struct IdHasher(u64);@@ -1194,7 +1194,9 @@ impl SessionConfig {self}- /// Customize [`OPT_TARGET_PARTITIONS`]+ /// Customize [`target_partitions`]+ ///+ /// [`target_partitions`]: crate::config::ExecutionOptions::target_partitionspub fn with_target_partitions(mut self, n: usize) -> Self {// partition count must be greater than zeroassert!(n > 0);@@ -1202,7 +1204,9 @@ impl SessionConfig {self}- /// get target_partitions+ /// Get [`target_partitions`]+ ///+ /// [`target_partitions`]: crate::config::ExecutionOptions::target_partitionspub fn target_partitions(&self) -> usize {self.options.execution.target_partitions}@@ -1330,7 +1334,7 @@ impl SessionConfig {/// Note that this method will eventually be deprecated and/// replaced by [`config_options`].///- /// [`config_options`]: SessionContext::config_option+ /// [`config_options`]: Self::config_optionspub fn to_props(&self) -> HashMap<String, String> {let mut map = HashMap::new();// copy configs from config_options@@ -1342,15 +1346,11 @@ impl SessionConfig {}/// Return a handle to the configuration options.- ///- /// [`config_options`]: SessionContext::config_optionpub fn config_options(&self) -> &ConfigOptions {&self.options}/// Return a mutable handle to the configuration options.- ///- /// [`config_options`]: SessionContext::config_optionpub fn config_options_mut(&mut self) -> &mut ConfigOptions {&mut self.options}@@ -1436,7 +1436,7 @@ impl From<ConfigOptions> for SessionConfig {/// Execution context for registering data sources and executing queries#[derive(Clone)]pub struct SessionState {- /// Uuid for the session+ /// UUID for the sessionsession_id: String,/// Responsible for optimizing a logical planoptimizer: Optimizer,@@ -1691,7 +1691,7 @@ impl SessionState {self}- /// Convert a sql string into an ast Statement+ /// Convert a SQL string into an AST Statementpub fn sql_to_statement(&self,sql: &str,@@ -1710,7 +1710,7 @@ impl SessionState {Ok(statement)}- /// Convert an ast Statement into a LogicalPlan+ /// Convert an AST Statement into a LogicalPlanpub async fn statement_to_plan(&self,statement: datafusion_sql::parser::Statement,@@ -2035,12 +2035,12 @@ impl TaskContext {&self.session_config}- /// Return the session_id of this [TaskContext]+ /// Return the `session_id` of this [TaskContext]pub fn session_id(&self) -> String {self.session_id.clone()}- /// Return the task_id of this [TaskContext]+ /// Return the `task_id` of this [TaskContext]pub fn task_id(&self) -> Option<String> {self.task_id.clone()}diff --git a/datafusion/core/src/lib.rs b/datafusion/core/src/lib.rsindex 04de7b1c9b..d227b1cc8c 100644--- a/datafusion/core/src/lib.rs+++ b/datafusion/core/src/lib.rs@@ -106,7 +106,7 @@//! Specifically, when DataFusion receives an SQL query, there are different steps//! that it passes through until a result is obtained. Broadly, they are://!-//! 1. The string is parsed to an Abstract syntax tree (AST) using [sqlparser](https://docs.rs/sqlparser/0.6.1/sqlparser/).+//! 1. The string is parsed to an Abstract syntax tree (AST) using [sqlparser](https://docs.rs/sqlparser/latest/sqlparser/).//! 2. The planner [`SqlToRel`](sql::planner::SqlToRel) converts logical expressions on the AST to logical expressions [`Expr`s](datafusion_expr::Expr).//! 3. The planner [`SqlToRel`](sql::planner::SqlToRel) converts logical nodes on the AST to a [`LogicalPlan`](datafusion_expr::LogicalPlan).//! 4. [`OptimizerRules`](optimizer::optimizer::OptimizerRule) are applied to the [`LogicalPlan`](datafusion_expr::LogicalPlan) to optimize it.@@ -144,7 +144,7 @@//!//! Broadly speaking,//!-//! * an [`ExecutionPlan`](physical_plan::ExecutionPlan) receives a partition number and asyncronosly returns+//! * an [`ExecutionPlan`](physical_plan::ExecutionPlan) receives a partition number and asynchronously returns//! an iterator over [`RecordBatch`](arrow::record_batch::RecordBatch)//! (a node-specific struct that implements [`RecordBatchReader`](arrow::record_batch::RecordBatchReader))//! * a [`PhysicalExpr`](physical_plan::PhysicalExpr) receives a [`RecordBatch`](arrow::record_batch::RecordBatch)@@ -159,9 +159,9 @@//! * Projection: [`ProjectionExec`](physical_plan::projection::ProjectionExec)//! * Filter: [`FilterExec`](physical_plan::filter::FilterExec)//! * Grouped and non-grouped aggregations: [`AggregateExec`](physical_plan::aggregates::AggregateExec)-//! * Hash Join: [`HashJoinExec`](physical_plan::hash_join::HashJoinExec)-//! * Cross Join: [`CrossJoinExec`](physical_plan::cross_join::CrossJoinExec)-//! * Sort Merge Join: [`SortMergeJoinExec`](physical_plan::sort_merge_join::SortMergeJoinExec)+//! * Hash Join: [`HashJoinExec`](physical_plan::joins::HashJoinExec)+//! * Cross Join: [`CrossJoinExec`](physical_plan::joins::CrossJoinExec)+//! * Sort Merge Join: [`SortMergeJoinExec`](physical_plan::joins::SortMergeJoinExec)//! * Union: [`UnionExec`](physical_plan::union::UnionExec)//! * Sort: [`SortExec`](physical_plan::sorts::sort::SortExec)//! * Coalesce partitions: [`CoalescePartitionsExec`](physical_plan::coalesce_partitions::CoalescePartitionsExec)@@ -180,7 +180,7 @@//! * declare and use user-defined scalar functions ([`ScalarUDF`](physical_plan::udf::ScalarUDF))//! * declare and use user-defined aggregate functions ([`AggregateUDF`](physical_plan::udaf::AggregateUDF))//!-//! you can find examples of each of them in examples section.+//! You can find examples of each of them in examples section.//!//! ## Examples//!diff --git a/datafusion/core/src/physical_optimizer/sort_enforcement.rs b/datafusion/core/src/physical_optimizer/sort_enforcement.rsindex 0eadfb7c2d..a59f35fc1d 100644--- a/datafusion/core/src/physical_optimizer/sort_enforcement.rs+++ b/datafusion/core/src/physical_optimizer/sort_enforcement.rs@@ -25,8 +25,12 @@//!//! A non-realistic but easy to follow example for sort removals: Assume that we//! somehow get the fragment-//! "SortExec: [nullable_col@0 ASC]",-//! " SortExec: [non_nullable_col@1 ASC]",+//!+//! ```text+//! SortExec: [nullable_col@0 ASC]+//! SortExec: [non_nullable_col@1 ASC]+//! ```+//!//! in the physical plan. The first sort is unnecessary since its result is overwritten//! by another SortExec. Therefore, this rule removes it from the physical plan.use crate::config::ConfigOptions;@@ -49,7 +53,7 @@ use itertools::{concat, izip};use std::iter::zip;use std::sync::Arc;-/// This rule inspects SortExec's in the given physical plan and removes the+/// This rule inspects `SortExec`'s in the given physical plan and removes the/// ones it can prove unnecessary.#[derive(Default)]pub struct EnforceSorting {}@@ -92,7 +96,7 @@ struct PlanWithCorrespondingSort {// For every child, keep a subtree of `ExecutionPlan`s starting from the// child until the `SortExec`(s) -- could be multiple for n-ary plans like// Union -- that determine the output ordering of the child. If the child- // has no connection to any sort, simpliy store None (and not a subtree).+ // has no connection to any sort, simply store None (and not a subtree).sort_onwards: Vec<Option<ExecTree>>,}diff --git a/datafusion/core/src/physical_plan/common.rs b/datafusion/core/src/physical_plan/common.rsindex f7acfaed6f..afe781c0f4 100644--- a/datafusion/core/src/physical_plan/common.rs+++ b/datafusion/core/src/physical_plan/common.rs@@ -112,7 +112,7 @@ pub fn merge_batches(}/// Merge a slice of record batch references into a single record batch, or-/// return None if the slice itself is empty. All the record batches inside the+/// return `None` if the slice itself is empty. All the record batches inside the/// slice must have the same schema.pub fn merge_multiple_batches(batches: &[&RecordBatch],@@ -322,7 +322,7 @@ pub fn transpose<T>(original: Vec<Vec<T>>) -> Vec<Vec<T>> {/// Calculates the "meet" of given orderings./// The meet is the finest ordering that satisfied by all the given-/// orderings, see https://en.wikipedia.org/wiki/Join_and_meet.+/// orderings, see <https://en.wikipedia.org/wiki/Join_and_meet>.pub fn get_meet_of_orderings(given: &[Arc<dyn ExecutionPlan>],) -> Option<&[PhysicalSortExpr]> {@@ -610,9 +610,9 @@ mod tests {pub struct IPCWriter {/// pathpub path: PathBuf,- /// Inner writer+ /// inner writerpub writer: FileWriter<File>,- /// bathes written+ /// batches writtenpub num_batches: u64,/// rows writtenpub num_rows: u64,diff --git a/datafusion/core/src/physical_plan/file_format/file_stream.rs b/datafusion/core/src/physical_plan/file_format/file_stream.rsindex 57f01a5cb7..a7fae47852 100644--- a/datafusion/core/src/physical_plan/file_format/file_stream.rs+++ b/datafusion/core/src/physical_plan/file_format/file_stream.rs@@ -51,6 +51,8 @@ pub type FileOpenFuture =/// Generic API for opening a file using an [`ObjectStore`] and resolving to a/// stream of [`RecordBatch`]+///+/// [`ObjectStore`]: object_store::ObjectStorepub trait FileOpener: Unpin {/// Asynchronously open the specified file and return a stream/// of [`RecordBatch`]diff --git a/datafusion/core/src/physical_plan/file_format/mod.rs b/datafusion/core/src/physical_plan/file_format/mod.rsindex a03b3681a4..60c1fd2e3c 100644--- a/datafusion/core/src/physical_plan/file_format/mod.rs+++ b/datafusion/core/src/physical_plan/file_format/mod.rs@@ -65,7 +65,7 @@ use std::{use super::{ColumnStatistics, Statistics};-/// convert logical type of partition column to physical type: Dictionary(UInt16, val_type)+/// Convert logical type of partition column to physical type: `Dictionary(UInt16, val_type)`pub fn partition_type_wrap(val_type: DataType) -> DataType {DataType::Dictionary(Box::new(DataType::UInt16), Box::new(val_type))}@@ -76,6 +76,9 @@ pub fn partition_type_wrap(val_type: DataType) -> DataType {pub struct FileScanConfig {/// Object store URL, used to get an [`ObjectStore`] instance from/// [`RuntimeEnv::object_store`]+ ///+ /// [`ObjectStore`]: object_store::ObjectStore+ /// [`RuntimeEnv::object_store`]: crate::execution::runtime_env::RuntimeEnv::object_storepub object_store_url: ObjectStoreUrl,/// Schema before `projection` is applied. It contains the all columns that may/// appear in the files. It does not include table partition columns@@ -96,7 +99,7 @@ pub struct FileScanConfig {/// Columns on which to project the data. Indexes that are higher than the/// number of columns of `file_schema` refer to `table_partition_cols`.pub projection: Option<Vec<usize>>,- /// The maximum number of records to read from this plan. If None,+ /// The maximum number of records to read from this plan. If `None`,/// all records after filtering are returned.pub limit: Option<usize>,/// The partitioning columns@@ -262,6 +265,7 @@ impl SchemaAdapter {/// Map a column index in the table schema to a column index in a particular/// file schema+ ////// Panics if index is not in range for the table schemapub(crate) fn map_column_index(&self,@@ -355,8 +359,8 @@ struct PartitionColumnProjector {impl PartitionColumnProjector {// Create a projector to insert the partitioning columns into batches read from files- // - projected_schema: the target schema with both file and partitioning columns- // - table_partition_cols: all the partitioning column names+ // - `projected_schema`: the target schema with both file and partitioning columns+ // - `table_partition_cols`: all the partitioning column namesfn new(projected_schema: SchemaRef, table_partition_cols: &[String]) -> Self {let mut idx_map = HashMap::new();for (partition_idx, partition_name) in table_partition_cols.iter().enumerate() {@@ -377,8 +381,8 @@ impl PartitionColumnProjector {// Transform the batch read from the file by inserting the partitioning columns// to the right positions as deduced from `projected_schema`- // - file_batch: batch read from the file, with internal projection applied- // - partition_values: the list of partition values, one for each partition column+ // - `file_batch`: batch read from the file, with internal projection applied+ // - `partition_values`: the list of partition values, one for each partition columnfn project(&mut self,file_batch: RecordBatch,diff --git a/datafusion/core/src/physical_plan/file_format/parquet/metrics.rs b/datafusion/core/src/physical_plan/file_format/parquet/metrics.rsindex 64e08753ab..915fb56680 100644--- a/datafusion/core/src/physical_plan/file_format/parquet/metrics.rs+++ b/datafusion/core/src/physical_plan/file_format/parquet/metrics.rs@@ -22,7 +22,9 @@ use crate::physical_plan::metrics::{/// Stores metrics about the parquet execution for a particular parquet file.////// This component is a subject to **change** in near future and is exposed for low level integrations-/// through [ParquetFileReaderFactory].+/// through [`ParquetFileReaderFactory`].+///+/// [`ParquetFileReaderFactory`]: super::ParquetFileReaderFactory#[derive(Debug, Clone)]pub struct ParquetFileMetrics {/// Number of times the predicate could not be evaluateddiff --git a/datafusion/core/src/physical_plan/metrics/mod.rs b/datafusion/core/src/physical_plan/metrics/mod.rsindex ebaec48e7b..95b579dbcf 100644--- a/datafusion/core/src/physical_plan/metrics/mod.rs+++ b/datafusion/core/src/physical_plan/metrics/mod.rs@@ -40,7 +40,7 @@ pub use tracker::MemTrackingMetrics;pub use value::{Count, Gauge, MetricValue, ScopedTimerGuard, Time, Timestamp};/// Something that tracks a value of interest (metric) of a DataFusion-/// [`super::ExecutionPlan`] execution.+/// [`ExecutionPlan`] execution.////// Typically [`Metric`]s are not created directly, but instead/// are created using [`MetricBuilder`] or methods on@@ -66,17 +66,19 @@ pub use value::{Count, Gauge, MetricValue, ScopedTimerGuard, Time, Timestamp};/// // As well as from the metrics set/// assert_eq!(metrics.clone_inner().output_rows(), Some(13));/// ```+///+/// [`ExecutionPlan`]: super::ExecutionPlan#[derive(Debug)]pub struct Metric {- /// The value the metric+ /// The value of the metricvalue: MetricValue,/// arbitrary name=value pairs identifiying this metriclabels: Vec<Label>,/// To which partition of an operators output did this metric- /// apply? If None means all partitions.+ /// apply? If `None` then means all partitions.partition: Option<usize>,}@@ -150,23 +152,25 @@ impl Metric {&self.labels}- /// return a reference to the value of this metric+ /// Return a reference to the value of this metricpub fn value(&self) -> &MetricValue {&self.value}- /// return a mutable reference to the value of this metric+ /// Return a mutable reference to the value of this metricpub fn value_mut(&mut self) -> &mut MetricValue {&mut self.value}- /// return a reference to the partition+ /// Return a reference to the partitionpub fn partition(&self) -> Option<usize> {self.partition}}/// A snapshot of the metrics for a particular ([`ExecutionPlan`]).+///+/// [`ExecutionPlan`]: super::ExecutionPlan#[derive(Default, Debug, Clone)]pub struct MetricsSet {metrics: Vec<Arc<Metric>>,@@ -183,41 +187,41 @@ impl MetricsSet {self.metrics.push(metric)}- /// Returns an interator across all metrics+ /// Returns an iterator across all metricspub fn iter(&self) -> impl Iterator<Item = &Arc<Metric>> {self.metrics.iter()}- /// convenience: return the number of rows produced, aggregated- /// across partitions or None if no metric is present+ /// Convenience: return the number of rows produced, aggregated+ /// across partitions or `None` if no metric is presentpub fn output_rows(&self) -> Option<usize> {self.sum(|metric| matches!(metric.value(), MetricValue::OutputRows(_))).map(|v| v.as_usize())}- /// convenience: return the count of spills, aggregated- /// across partitions or None if no metric is present+ /// Convenience: return the count of spills, aggregated+ /// across partitions or `None` if no metric is presentpub fn spill_count(&self) -> Option<usize> {self.sum(|metric| matches!(metric.value(), MetricValue::SpillCount(_))).map(|v| v.as_usize())}- /// convenience: return the total byte size of spills, aggregated- /// across partitions or None if no metric is present+ /// Convenience: return the total byte size of spills, aggregated+ /// across partitions or `None` if no metric is presentpub fn spilled_bytes(&self) -> Option<usize> {self.sum(|metric| matches!(metric.value(), MetricValue::SpilledBytes(_))).map(|v| v.as_usize())}- /// convenience: return the amount of elapsed CPU time spent,- /// aggregated across partitions or None if no metric is present+ /// Convenience: return the amount of elapsed CPU time spent,+ /// aggregated across partitions or `None` if no metric is presentpub fn elapsed_compute(&self) -> Option<usize> {self.sum(|metric| matches!(metric.value(), MetricValue::ElapsedCompute(_))).map(|v| v.as_usize())}/// Sums the values for metrics for which `f(metric)` returns- /// true, and returns the value. Returns None if no metrics match+ /// `true`, and returns the value. Returns `None` if no metrics match/// the predicate.pub fn sum<F>(&self, mut f: F) -> Option<MetricValue>where@@ -241,8 +245,8 @@ impl MetricsSet {Some(accum)}- /// returns the sum of all the metrics with the specified name- /// the returned set.+ /// Returns the sum of all the metrics with the specified name+ /// in the returned set.pub fn sum_by_name(&self, metric_name: &str) -> Option<MetricValue> {self.sum(|m| match m.value() {MetricValue::Count { name, .. } => name == metric_name,@@ -258,7 +262,7 @@ impl MetricsSet {})}- /// Returns returns a new derived `MetricsSet` where all metrics+ /// Returns a new derived `MetricsSet` where all metrics/// that had the same name have been/// aggregated together. The resulting `MetricsSet` has all/// metrics with `Partition=None`@@ -298,7 +302,7 @@ impl MetricsSet {self}- /// remove all timestamp metrics (for more compact display+ /// Remove all timestamp metrics (for more compact display)pub fn timestamps_removed(self) -> Self {let Self { metrics } = self;@@ -312,7 +316,7 @@ impl MetricsSet {}impl Display for MetricsSet {- /// format the MetricsSet as a single string+ /// Format the [`MetricsSet`] as a single stringfn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {let mut is_first = true;for i in self.metrics.iter() {@@ -328,15 +332,17 @@ impl Display for MetricsSet {}}-/// A set of [`Metric`] for an individual "operator" (e.g. `&dyn+/// A set of [`Metric`]s for an individual "operator" (e.g. `&dyn/// ExecutionPlan`).///-/// This structure is intended as a convenience for [`super::ExecutionPlan`]+/// This structure is intended as a convenience for [`ExecutionPlan`]/// implementations so they can generate different streams for multiple/// partitions but easily report them together.////// Each `clone()` of this structure will add metrics to the same/// underlying metrics set+///+/// [`ExecutionPlan`]: super::ExecutionPlan#[derive(Default, Debug, Clone)]pub struct ExecutionPlanMetricsSet {inner: Arc<Mutex<MetricsSet>>,@@ -355,14 +361,14 @@ impl ExecutionPlanMetricsSet {self.inner.lock().push(metric)}- /// Return a clone of the inner MetricsSet+ /// Return a clone of the inner [`MetricsSet`]pub fn clone_inner(&self) -> MetricsSet {let guard = self.inner.lock();(*guard).clone()}}-/// name=value pairs identifiying a metric. This concept is called various things+/// `name=value` pairs identifiying a metric. This concept is called various things/// in various different systems:////// "labels" in@@ -374,7 +380,7 @@ impl ExecutionPlanMetricsSet {/// etc.////// As the name and value are expected to mostly be constant strings,-/// use a `Cow` to avoid copying / allocations in this common case.+/// use a [`Cow`] to avoid copying / allocations in this common case.#[derive(Debug, Clone, PartialEq, Eq, Hash)]pub struct Label {name: Cow<'static, str>,@@ -382,7 +388,7 @@ pub struct Label {}impl Label {- /// Create a new Label+ /// Create a new [`Label`]pub fn new(name: impl Into<Cow<'static, str>>,value: impl Into<Cow<'static, str>>,@@ -392,12 +398,12 @@ impl Label {Self { name, value }}- /// Return the name of this label+ /// Returns the name of this labelpub fn name(&self) -> &str {self.name.as_ref()}- /// Return the value of this label+ /// Returns the value of this labelpub fn value(&self) -> &str {self.value.as_ref()}diff --git a/datafusion/core/src/scheduler/mod.rs b/datafusion/core/src/scheduler/mod.rsindex 922fa1c3e1..790c990467 100644--- a/datafusion/core/src/scheduler/mod.rs+++ b/datafusion/core/src/scheduler/mod.rs@@ -26,14 +26,14 @@//! chunks called pipelines. Each pipeline may consist of one or more nodes from the//! [`ExecutionPlan`] tree.//!-//! The scheduler then maintains a list of pending [`Task`], that identify a partition within+//! The scheduler then maintains a list of pending `Task`s, that identify a partition within//! a particular pipeline that may be able to make progress on some "morsel" of data. These-//! [`Task`] are then scheduled on the worker pool, with a preference for scheduling work+//! `Task`s are then scheduled on the worker pool, with a preference for scheduling work//! on a given "morsel" on the same thread that produced it.//!//! # Rayon//!-//! Under-the-hood these [`Task`] are scheduled by [rayon], which is a lightweight, work-stealing+//! Under-the-hood these `Task`s are scheduled by [rayon], which is a lightweight, work-stealing//! scheduler optimised for CPU-bound workloads. Pipelines may exploit this fact, and use [rayon]'s//! structured concurrency primitives to express additional parallelism that may be exploited//! if there are idle threads available at runtime@@ -100,7 +100,7 @@ pub struct SchedulerBuilder {}impl SchedulerBuilder {- /// Create a new [`SchedulerConfig`] with the provided number of threads+ /// Create a new [`SchedulerBuilder`] with the provided number of threadspub fn new(num_threads: usize) -> Self {let builder = ThreadPoolBuilder::new().num_threads(num_threads)@@ -144,6 +144,8 @@ impl Scheduler {////// Returns a [`ExecutionResults`] that can be used to receive results as they are produced,/// as a [`futures::Stream`] of [`RecordBatch`]+ ///+ /// [`RecordBatch`]: arrow::record_batch::RecordBatchpub fn schedule(&self,plan: Arc<dyn ExecutionPlan>,diff --git a/datafusion/expr/src/expr_rewriter.rs b/datafusion/expr/src/expr_rewriter.rsindex 7f084548ca..af672a85ce 100644--- a/datafusion/expr/src/expr_rewriter.rs+++ b/datafusion/expr/src/expr_rewriter.rs@@ -75,7 +75,7 @@ pub enum RewriteRecursion {/// mutate(BinaryExpr(GT))/// ```///-/// If an Err result is returned, recursion is stopped immediately+/// If an `Err` result is returned, recursion is stopped immediately////// If [`false`] is returned on a call to pre_visit, no/// children of that expression are visited, nor is mutate@@ -84,6 +84,8 @@ pub enum RewriteRecursion {/// # See Also:/// * [`Expr::accept`] to drive a rewriter through an [`Expr`]/// * [`rewrite_expr`]: For rewriting an [`Expr`] using functions+///+/// [`Expr::accept`]: crate::expr_visitor::ExprVisitable::acceptpub trait ExprRewriter<E: ExprRewritable = Expr>: Sized {/// Invoked before any children of `expr` are rewritten //// visited. Default implementation returns `Ok(RewriteRecursion::Continue)`@@ -96,14 +98,14 @@ pub trait ExprRewriter<E: ExprRewritable = Expr>: Sized {fn mutate(&mut self, expr: E) -> Result<E>;}-/// a trait for marking types that are rewritable by [ExprRewriter]+/// A trait for marking types that are rewritable by [ExprRewriter]pub trait ExprRewritable: Sized {- /// rewrite the expression tree using the given [ExprRewriter]+ /// Rewrite the expression tree using the given [ExprRewriter]fn rewrite<R: ExprRewriter<Self>>(self, rewriter: &mut R) -> Result<Self>;}impl ExprRewritable for Expr {- /// see comments on [`ExprRewritable`] for details+ /// See comments on [`ExprRewritable`] for detailsfn rewrite<R>(self, rewriter: &mut R) -> Result<Self>whereR: ExprRewriter<Self>,@@ -331,7 +333,7 @@ where.transpose()}-/// rewrite a `Vec` of `Expr`s with the rewriter+/// Rewrite a `Vec` of `Expr`s with the rewriterfn rewrite_vec<R>(v: Vec<Expr>, rewriter: &mut R) -> Result<Vec<Expr>>whereR: ExprRewriter,@@ -339,13 +341,13 @@ wherev.into_iter().map(|expr| expr.rewrite(rewriter)).collect()}-/// Recursively call [`Column::normalize_with_schemas`] on all Column expressions+/// Recursively call [`Column::normalize_with_schemas`] on all [`Column`] expressions/// in the `expr` expression tree.pub fn normalize_col(expr: Expr, plan: &LogicalPlan) -> Result<Expr> {normalize_col_with_schemas(expr, &plan.all_schemas(), &plan.using_columns()?)}-/// Recursively call [`Column::normalize_with_schemas`] on all Column expressions+/// Recursively call [`Column::normalize_with_schemas`] on all [`Column`] expressions/// in the `expr` expression tree.pub fn normalize_col_with_schemas(expr: Expr,@@ -363,7 +365,7 @@ pub fn normalize_col_with_schemas(})}-/// Recursively normalize all Column expressions in a list of expression trees+/// Recursively normalize all [`Column`] expressions in a list of expression treespub fn normalize_cols(exprs: impl IntoIterator<Item = impl Into<Expr>>,plan: &LogicalPlan,@@ -374,8 +376,8 @@ pub fn normalize_cols(.collect()}-/// Recursively replace all Column expressions in a given expression tree with Column expressions-/// provided by the hash map argument.+/// Recursively replace all [`Column`] expressions in a given expression tree with+/// `Column` expressions provided by the hash map argument.pub fn replace_col(e: Expr, replace_map: &HashMap<&Column, &Column>) -> Result<Expr> {rewrite_expr(e, |expr| {if let Expr::Column(c) = &expr {@@ -408,7 +410,7 @@ pub fn unnormalize_col(expr: Expr) -> Expr {.expect("Unnormalize is infallable")}-/// Recursively un-normalize all Column expressions in a list of expression trees+/// Recursively un-normalize all [`Column`] expressions in a list of expression trees#[inline]pub fn unnormalize_cols(exprs: impl IntoIterator<Item = Expr>) -> Vec<Expr> {exprs.into_iter().map(unnormalize_col).collect()diff --git a/datafusion/optimizer/src/inline_table_scan.rs b/datafusion/optimizer/src/inline_table_scan.rsindex 1783cf0a2a..39e7d43845 100644--- a/datafusion/optimizer/src/inline_table_scan.rs+++ b/datafusion/optimizer/src/inline_table_scan.rs@@ -24,7 +24,7 @@ use datafusion_common::Result;use datafusion_expr::{logical_plan::LogicalPlan, Expr, LogicalPlanBuilder, TableScan};/// Optimization rule that inlines TableScan that provide a [LogicalPlan]-/// ([DataFrame] / [ViewTable])+/// (DataFrame / ViewTable)#[derive(Default)]pub struct InlineTableScan;diff --git a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rsindex c789141671..6ee1d01721 100644--- a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs+++ b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs@@ -48,6 +48,8 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {/// Create a new `ExprSimplifier` with the given `info` such as an/// instance of [`SimplifyContext`]. See/// [`simplify`](Self::simplify) for an example.+ ///+ /// [`SimplifyContext`]: crate::simplify_expressions::context::SimplifyContextpub fn new(info: S) -> Self {Self { info }}@@ -143,8 +145,8 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {/// Note it does not handle algebraic rewrites such as `(a or false)`/// --> `a`, which is handled by [`Simplifier`]struct ConstEvaluator<'a> {- /// can_evaluate is used during the depth-first-search of the- /// Expr tree to track if any siblings (or their descendants) were+ /// `can_evaluate` is used during the depth-first-search of the+ /// `Expr` tree to track if any siblings (or their descendants) were/// non evaluatable (e.g. had a column reference or volatile/// function)///@@ -152,9 +154,9 @@ struct ConstEvaluator<'a> {/// traversal when we are N levels deep in the tree, one entry for/// this Expr and each of its parents.///- /// After visiting all siblings if can_evauate.top() is true, that+ /// After visiting all siblings if `can_evauate.top()`` is true, that/// means there were no non evaluatable siblings (or their- /// descendants) so this Expr can be evaluated+ /// descendants) so this `Expr` can be evaluatedcan_evaluate: Vec<bool>,execution_props: &'a ExecutionProps,diff --git a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rsindex 79cebfb664..1e9f902f90 100644--- a/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs+++ b/datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs@@ -36,6 +36,7 @@ use datafusion_physical_expr::execution_props::ExecutionProps;/// is optimized to/// `Filter: b > 2`///+/// [`Expr`]: datafusion_expr::Expr#[derive(Default)]pub struct SimplifyExpressions {}diff --git a/datafusion/physical-expr/src/aggregate/hyperloglog.rs b/datafusion/physical-expr/src/aggregate/hyperloglog.rsindex 3e28e29768..bf25ecebcd 100644--- a/datafusion/physical-expr/src/aggregate/hyperloglog.rs+++ b/datafusion/physical-expr/src/aggregate/hyperloglog.rs@@ -20,7 +20,7 @@//! `hyperloglog` is a module that contains a modified version//! of [redis's implementation](https://github.com/redis/redis/blob/4930d19e70c391750479951022e207e19111eb55/src/hyperloglog.c)//! with some modification based on strong assumption of usage-//! within datafusion, so that [`crate::logical_plan::approx_distinct`] function can+//! within datafusion, so that [`datafusion_expr::approx_distinct`] function can//! be efficiently implemented.//!//! Specifically, like Redis's version, this HLL structure uses@@ -40,10 +40,10 @@ use std::marker::PhantomData;/// The greater is P, the smaller the error.const HLL_P: usize = 14_usize;-/// the number of bits of the hash value used determining the number of leading zeros+/// The number of bits of the hash value used determining the number of leading zerosconst HLL_Q: usize = 64_usize - HLL_P;const NUM_REGISTERS: usize = 1_usize << HLL_P;-/// mask to obtain index into the registers+/// Mask to obtain index into the registersconst HLL_P_MASK: u64 = (NUM_REGISTERS as u64) - 1;#[derive(Clone, Debug)]diff --git a/datafusion/physical-expr/src/execution_props.rs b/datafusion/physical-expr/src/execution_props.rsindex 800e355831..d9f53dbd64 100644--- a/datafusion/physical-expr/src/execution_props.rs+++ b/datafusion/physical-expr/src/execution_props.rs@@ -27,10 +27,12 @@ use std::sync::Arc;////// It is important that this structure be cheap to create as it is/// done so during predicate pruning and expression simplification+///+/// [`LogicalPlan`]: datafusion_expr::LogicalPlan#[derive(Clone)]pub struct ExecutionProps {pub query_execution_start_time: DateTime<Utc>,- /// providers for scalar variables+ /// Providers for scalar variablespub var_providers: Option<HashMap<VarType, Arc<dyn VarProvider + Send + Sync>>>,}@@ -73,7 +75,7 @@ impl ExecutionProps {old_provider}- /// Returns the provider for the var_type, if any+ /// Returns the provider for the `var_type`, if anypub fn get_var_provider(&self,var_type: VarType,diff --git a/datafusion/physical-expr/src/window/window_expr.rs b/datafusion/physical-expr/src/window/window_expr.rsindex a38d5de542..065d26fef0 100644--- a/datafusion/physical-expr/src/window/window_expr.rs+++ b/datafusion/physical-expr/src/window/window_expr.rs@@ -40,7 +40,7 @@ pub trait WindowExpr: Send + Sync + Debug {/// downcast to a specific implementation.fn as_any(&self) -> &dyn Any;- /// the field of the final result of this window function.+ /// The field of the final result of this window function.fn field(&self) -> Result<Field>;/// Human readable name such as `"MIN(c2)"` or `"RANK()"`. The default@@ -49,13 +49,13 @@ pub trait WindowExpr: Send + Sync + Debug {"WindowExpr: default name"}- /// expressions that are passed to the WindowAccumulator.+ /// Expressions that are passed to the WindowAccumulator./// Functions which take a single input argument, such as `sum`, return a single [`datafusion_expr::expr::Expr`],/// others (e.g. `cov`) return many.fn expressions(&self) -> Vec<Arc<dyn PhysicalExpr>>;- /// evaluate the window function arguments against the batch and return- /// array ref, normally the resulting vec is a single element one.+ /// Evaluate the window function arguments against the batch and return+ /// array ref, normally the resulting `Vec` is a single element one.fn evaluate_args(&self, batch: &RecordBatch) -> Result<Vec<ArrayRef>> {self.expressions().iter()@@ -64,7 +64,7 @@ pub trait WindowExpr: Send + Sync + Debug {.collect()}- /// evaluate the window function values against the batch+ /// Evaluate the window function values against the batchfn evaluate(&self, batch: &RecordBatch) -> Result<ArrayRef>;/// Evaluate the window function against the batch. This function facilitates@@ -80,8 +80,8 @@ pub trait WindowExpr: Send + Sync + Debug {)))}- /// evaluate the partition points given the sort columns; if the sort columns are- /// empty then the result will be a single element vec of the whole column rows.+ /// Evaluate the partition points given the sort columns; if the sort columns are+ /// empty then the result will be a single element `Vec` of the whole column rows.fn evaluate_partition_points(&self,num_rows: usize,@@ -99,13 +99,13 @@ pub trait WindowExpr: Send + Sync + Debug {}}- /// expressions that's from the window function's partition by clause, empty if absent+ /// Expressions that's from the window function's partition by clause, empty if absentfn partition_by(&self) -> &[Arc<dyn PhysicalExpr>];- /// expressions that's from the window function's order by clause, empty if absent+ /// Expressions that's from the window function's order by clause, empty if absentfn order_by(&self) -> &[PhysicalSortExpr];- /// get order by columns, empty if absent+ /// Get order by columns, empty if absentfn order_by_columns(&self, batch: &RecordBatch) -> Result<Vec<SortColumn>> {self.order_by().iter()@@ -113,14 +113,14 @@ pub trait WindowExpr: Send + Sync + Debug {.collect::<Result<Vec<SortColumn>>>()}- /// get sort columns that can be used for peer evaluation, empty if absent+ /// Get sort columns that can be used for peer evaluation, empty if absentfn sort_columns(&self, batch: &RecordBatch) -> Result<Vec<SortColumn>> {let order_by_columns = self.order_by_columns(batch)?;Ok(order_by_columns)}- /// Get values columns(argument of Window Function)- /// and order by columns (columns of the ORDER BY expression)used in evaluators+ /// Get values columns (argument of Window Function)+ /// and order by columns (columns of the ORDER BY expression) used in evaluatorsfn get_values_orderbys(&self,record_batch: &RecordBatch,@@ -369,13 +369,14 @@ pub struct WindowAggState {pub struct PartitionBatchState {/// The record_batch belonging to current partitionpub record_batch: RecordBatch,- /// flag indicating whether we have received all data for this partition+ /// Flag indicating whether we have received all data for this partitionpub is_end: bool,}-/// key for IndexMap for each unique partition-/// For instance, if window frame is OVER(PARTITION BY a,b)-/// PartitionKey would consist of unique [a,b] pairs+/// Key for IndexMap for each unique partition+///+/// For instance, if window frame is `OVER(PARTITION BY a,b)`,+/// PartitionKey would consist of unique `[a,b]` pairspub type PartitionKey = Vec<ScalarValue>;#[derive(Debug)]diff --git a/datafusion/proto/src/bytes/mod.rs b/datafusion/proto/src/bytes/mod.rsindex a0b678f632..30343960c4 100644--- a/datafusion/proto/src/bytes/mod.rs+++ b/datafusion/proto/src/bytes/mod.rs@@ -52,25 +52,30 @@ mod registry;/// // Convert it to an opaque form/// let bytes = expr.to_bytes().unwrap();///-/// // Decode bytes from somewhere (over network, etc.+/// // Decode bytes from somewhere (over network, etc.)/// let decoded_expr = Expr::from_bytes(&bytes).unwrap();/// assert_eq!(expr, decoded_expr);/// ```pub trait Serializeable: Sized {- /// Convert `self` to an opaque byt stream+ /// Convert `self` to an opaque byte streamfn to_bytes(&self) -> Result<Bytes>;- /// Convert `bytes` (the output of [`to_bytes`] back into an+ /// Convert `bytes` (the output of [`to_bytes`]) back into an/// object. This will error if the serialized bytes contain any/// user defined functions, in which case use/// [`from_bytes_with_registry`]+ ///+ /// [`to_bytes`]: Self::to_bytes+ /// [`from_bytes_with_registry`]: Self::from_bytes_with_registryfn from_bytes(bytes: &[u8]) -> Result<Self> {Self::from_bytes_with_registry(bytes, ®istry::NoRegistry {})}- /// Convert `bytes` (the output of [`to_bytes`] back into an+ /// Convert `bytes` (the output of [`to_bytes`]) back into an/// object resolving user defined functions with the specified/// `registry`+ ///+ /// [`to_bytes`]: Self::to_bytesfn from_bytes_with_registry(bytes: &[u8],registry: &dyn FunctionRegistry,@@ -149,7 +154,7 @@ pub fn logical_plan_to_bytes(plan: &LogicalPlan) -> Result<Bytes> {logical_plan_to_bytes_with_extension_codec(plan, &extension_codec)}-/// Serialize a LogicalPlan as json+/// Serialize a LogicalPlan as JSON#[cfg(feature = "json")]pub fn logical_plan_to_json(plan: &LogicalPlan) -> Result<String> {let extension_codec = DefaultLogicalExtensionCodec {};@@ -176,7 +181,7 @@ pub fn logical_plan_to_bytes_with_extension_codec(Ok(buffer.into())}-/// Deserialize a LogicalPlan from json+/// Deserialize a LogicalPlan from JSON#[cfg(feature = "json")]pub fn logical_plan_from_json(json: &str, ctx: &SessionContext) -> Result<LogicalPlan> {let back: protobuf::LogicalPlanNode = serde_json::from_str(json)@@ -212,7 +217,7 @@ pub fn physical_plan_to_bytes(plan: Arc<dyn ExecutionPlan>) -> Result<Bytes> {physical_plan_to_bytes_with_extension_codec(plan, &extension_codec)}-/// Serialize a PhysicalPlan as json+/// Serialize a PhysicalPlan as JSON#[cfg(feature = "json")]pub fn physical_plan_to_json(plan: Arc<dyn ExecutionPlan>) -> Result<String> {let extension_codec = DefaultPhysicalExtensionCodec {};@@ -239,7 +244,7 @@ pub fn physical_plan_to_bytes_with_extension_codec(Ok(buffer.into())}-/// Deserialize a PhysicalPlan from json+/// Deserialize a PhysicalPlan from JSON#[cfg(feature = "json")]pub fn physical_plan_from_json(json: &str,diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rsindex 5aaf79997b..3dcf2fdb4e 100644--- a/datafusion/proto/src/logical_plan/from_proto.rs+++ b/datafusion/proto/src/logical_plan/from_proto.rs@@ -113,13 +113,13 @@ impl Error {pub trait FromOptionalField<T> {/// Converts an optional protobuf field to an option of a different type///- /// Returns None if the option is None, otherwise calls [`FromField::field`]+ /// Returns None if the option is None, otherwise calls [`TryInto::try_into`]/// on the contained data, returning any error encounteredfn optional(self) -> Result<Option<T>, Error>;/// Converts an optional protobuf field to a different type, returning an error if None///- /// Returns `Error::MissingRequiredField` if None, otherwise calls [`FromField::field`]+ /// Returns `Error::MissingRequiredField` if None, otherwise calls [`TryInto::try_into`]/// on the contained data, returning any error encounteredfn required(self, field: impl Into<String>) -> Result<T, Error>;}diff --git a/datafusion/row/src/writer.rs b/datafusion/row/src/writer.rsindex 451d84f17b..314108fbac 100644--- a/datafusion/row/src/writer.rs+++ b/datafusion/row/src/writer.rs@@ -15,7 +15,7 @@// specific language governing permissions and limitations// under the License.-//! [`RowWriter`] writes [`RecordBatch`]es to Vec<u8> to stitch attributes together+//! [`RowWriter`] writes [`RecordBatch`]es to `Vec<u8>` to stitch attributes togetheruse crate::layout::{estimate_row_width, RowLayout, RowType};use arrow::array::*;@@ -56,7 +56,7 @@ pub fn write_batch_unchecked(offsets}-/// bench interpreted version write+/// Bench interpreted version write#[inline(never)]pub fn bench_write_batch(batches: &[Vec<RecordBatch>],@@ -100,7 +100,7 @@ macro_rules! fn_set_idx {};}-/// Reusable row writer backed by Vec<u8>+/// Reusable row writer backed by `Vec<u8>`////// ```text/// ┌ ─ ─ ─ ─ ─ ─ ─ ─@@ -120,7 +120,7 @@ macro_rules! fn_set_idx {pub struct RowWriter {/// Layout on how to write each fieldlayout: RowLayout,- /// buffer for the current tuple been written.+ /// Buffer for the current tuple being written.data: Vec<u8>,/// Length in bytes for the current tuple, 8-bytes word aligned.pub(crate) row_width: usize,@@ -131,7 +131,7 @@ pub struct RowWriter {}impl RowWriter {- /// new+ /// Newpub fn new(schema: &Schema, row_type: RowType) -> Self {let layout = RowLayout::new(schema, row_type);let init_capacity = estimate_row_width(schema, &layout);diff --git a/docs/source/user-guide/configs.md b/docs/source/user-guide/configs.mdindex ddfbc4e6e5..37b750c59b 100644--- a/docs/source/user-guide/configs.md+++ b/docs/source/user-guide/configs.md@@ -35,40 +35,40 @@ Values are parsed according to the [same rules used in casts from Utf8](https://If the value in the environment variable cannot be cast to the type of the configuration option, the default value will be used instead and a warning emitted.Environment variables are read during `SessionConfig` initialisation so they must be set beforehand and will not affect running sessions.-| key | default | description |-| --------------------------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| datafusion.catalog.create_default_catalog_and_schema | true | Whether the default catalog and schema should be created automatically. |-| datafusion.catalog.default_catalog | datafusion | The default catalog name - this impacts what SQL queries use if not specified |-| datafusion.catalog.default_schema | public | The default schema name - this impacts what SQL queries use if not specified |-| datafusion.catalog.information_schema | false | Should DataFusion provide access to `information_schema` virtual tables for displaying schema information |-| datafusion.catalog.location | NULL | Location scanned to load tables for `default` schema |-| datafusion.catalog.format | NULL | Type of `TableProvider` to use when loading `default` schema |-| datafusion.catalog.has_header | false | If the file has a header |-| datafusion.execution.batch_size | 8192 | Default batch size while creating new batches, it's especially useful for buffer-in-memory batches since creating tiny batches would results in too much metadata memory consumption |-| datafusion.execution.coalesce_batches | true | When set to true, record batches will be examined between each operator and small batches will be coalesced into larger batches. This is helpful when there are highly selective filters or joins that could produce tiny output batches. The target batch size is determined by the configuration setting |-| datafusion.execution.collect_statistics | false | Should DataFusion collect statistics after listing files |-| datafusion.execution.target_partitions | 0 | Number of partitions for query execution. Increasing partitions can increase concurrency. Defaults to the number of cpu cores on the system |-| datafusion.execution.time_zone | +00:00 | The default time zone Some functions, e.g. EXTRACT(HOUR from SOME_TIME), shift the underlying datetime according to this time zone, and then extract the hour |-| datafusion.execution.parquet.enable_page_index | false | If true, uses parquet data page level metadata (Page Index) statistics to reduce the number of rows decoded. |-| datafusion.execution.parquet.pruning | true | If true, the parquet reader attempts to skip entire row groups based on the predicate in the query and the metadata (min/max values) stored in the parquet file |-| datafusion.execution.parquet.skip_metadata | true | If true, the parquet reader skip the optional embedded metadata that may be in the file Schema. This setting can help avoid schema conflicts when querying multiple parquet files with schemas containing compatible types but different metadata |-| datafusion.execution.parquet.metadata_size_hint | NULL | If specified, the parquet reader will try and fetch the last `size_hint` bytes of the parquet file optimistically. If not specified, two read are required: One read to fetch the 8-byte parquet footer and another to fetch the metadata length encoded in the footer |-| datafusion.execution.parquet.pushdown_filters | false | If true, filter expressions are be applied during the parquet decoding operation to reduce the number of rows decoded |-| datafusion.execution.parquet.reorder_filters | false | If true, filter expressions evaluated during the parquet decoding operation will be reordered heuristically to minimize the cost of evaluation. If false, the filters are applied in the same order as written in the query |-| datafusion.optimizer.enable_round_robin_repartition | true | When set to true, the physical plan optimizer will try to add round robin repartition to increase parallelism to leverage more CPU cores |-| datafusion.optimizer.filter_null_join_keys | false | When set to true, the optimizer will insert filters before a join between a nullable and non-nullable column to filter out nulls on the nullable side. This filter can add additional overhead when the file format does not fully support predicate push down. |-| datafusion.optimizer.repartition_aggregations | true | Should DataFusion repartition data using the aggregate keys to execute aggregates in parallel using the provided `target_partitions` level" |-| datafusion.optimizer.repartition_file_min_size | 10485760 | Minimum total files size in bytes to perform file scan repartitioning. |-| datafusion.optimizer.repartition_joins | true | Should DataFusion repartition data using the join keys to execute joins in parallel using the provided `target_partitions` level" |-| datafusion.optimizer.repartition_file_scans | false | When set to true, file groups will be repartitioned to achieve maximum parallelism. Currently supported only for Parquet format in which case multiple row groups from the same file may be read concurrently. If false then each row group is read serially, though different files may be read in parallel. |-| datafusion.optimizer.repartition_windows | true | Should DataFusion repartition data using the partitions keys to execute window functions in parallel using the provided `target_partitions` level" |-| datafusion.optimizer.repartition_sorts | true | Should DataFusion execute sorts in a per-partition fashion and merge afterwards instead of coalescing first and sorting globally With this flag is enabled, plans in the form below "SortExec: [a@0 ASC]", " CoalescePartitionsExec", " RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", would turn into the plan below which performs better in multithreaded environments "SortPreservingMergeExec: [a@0 ASC]", " SortExec: [a@0 ASC]", " RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", |-| datafusion.optimizer.skip_failed_rules | true | When set to true, the logical plan optimizer will produce warning messages if any optimization rules produce errors and then proceed to the next rule. When set to false, any rules that produce errors will cause the query to fail |-| datafusion.optimizer.max_passes | 3 | Number of times that the optimizer will attempt to optimize the plan |-| datafusion.optimizer.top_down_join_key_reordering | true | When set to true, the physical plan optimizer will run a top down process to reorder the join keys |-| datafusion.optimizer.prefer_hash_join | true | When set to true, the physical plan optimizer will prefer HashJoin over SortMergeJoin. HashJoin can work more efficiently than SortMergeJoin but consumes more memory |-| datafusion.optimizer.hash_join_single_partition_threshold | 1048576 | The maximum estimated size in bytes for one input side of a HashJoin will be collected into a single partition |-| datafusion.explain.logical_plan_only | false | When set to true, the explain statement will only print logical plans |-| datafusion.explain.physical_plan_only | false | When set to true, the explain statement will only print physical plans |-| datafusion.sql_parser.parse_float_as_decimal | false | When set to true, sql parser will parse float as decimal type |-| datafusion.sql_parser.enable_ident_normalization | true | When set to true, sql parser will normalize ident(convert ident to lowercase when not quoted) |+| key | default | description |+| --------------------------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| datafusion.catalog.create_default_catalog_and_schema | true | Whether the default catalog and schema should be created automatically. |+| datafusion.catalog.default_catalog | datafusion | The default catalog name - this impacts what SQL queries use if not specified |+| datafusion.catalog.default_schema | public | The default schema name - this impacts what SQL queries use if not specified |+| datafusion.catalog.information_schema | false | Should DataFusion provide access to `information_schema` virtual tables for displaying schema information |+| datafusion.catalog.location | NULL | Location scanned to load tables for `default` schema |+| datafusion.catalog.format | NULL | Type of `TableProvider` to use when loading `default` schema |+| datafusion.catalog.has_header | false | If the file has a header |+| datafusion.execution.batch_size | 8192 | Default batch size while creating new batches, it's especially useful for buffer-in-memory batches since creating tiny batches would result in too much metadata memory consumption |+| datafusion.execution.coalesce_batches | true | When set to true, record batches will be examined between each operator and small batches will be coalesced into larger batches. This is helpful when there are highly selective filters or joins that could produce tiny output batches. The target batch size is determined by the configuration setting |+| datafusion.execution.collect_statistics | false | Should DataFusion collect statistics after listing files |+| datafusion.execution.target_partitions | 0 | Number of partitions for query execution. Increasing partitions can increase concurrency. Defaults to the number of CPU cores on the system |+| datafusion.execution.time_zone | +00:00 | The default time zone Some functions, e.g. `EXTRACT(HOUR from SOME_TIME)`, shift the underlying datetime according to this time zone, and then extract the hour |+| datafusion.execution.parquet.enable_page_index | false | If true, uses parquet data page level metadata (Page Index) statistics to reduce the number of rows decoded. |+| datafusion.execution.parquet.pruning | true | If true, the parquet reader attempts to skip entire row groups based on the predicate in the query and the metadata (min/max values) stored in the parquet file |+| datafusion.execution.parquet.skip_metadata | true | If true, the parquet reader skip the optional embedded metadata that may be in the file Schema. This setting can help avoid schema conflicts when querying multiple parquet files with schemas containing compatible types but different metadata |+| datafusion.execution.parquet.metadata_size_hint | NULL | If specified, the parquet reader will try and fetch the last `size_hint` bytes of the parquet file optimistically. If not specified, two reads are required: One read to fetch the 8-byte parquet footer and another to fetch the metadata length encoded in the footer |+| datafusion.execution.parquet.pushdown_filters | false | If true, filter expressions are be applied during the parquet decoding operation to reduce the number of rows decoded |+| datafusion.execution.parquet.reorder_filters | false | If true, filter expressions evaluated during the parquet decoding operation will be reordered heuristically to minimize the cost of evaluation. If false, the filters are applied in the same order as written in the query |+| datafusion.optimizer.enable_round_robin_repartition | true | When set to true, the physical plan optimizer will try to add round robin repartitioning to increase parallelism to leverage more CPU cores |+| datafusion.optimizer.filter_null_join_keys | false | When set to true, the optimizer will insert filters before a join between a nullable and non-nullable column to filter out nulls on the nullable side. This filter can add additional overhead when the file format does not fully support predicate push down. |+| datafusion.optimizer.repartition_aggregations | true | Should DataFusion repartition data using the aggregate keys to execute aggregates in parallel using the provided `target_partitions` level |+| datafusion.optimizer.repartition_file_min_size | 10485760 | Minimum total files size in bytes to perform file scan repartitioning. |+| datafusion.optimizer.repartition_joins | true | Should DataFusion repartition data using the join keys to execute joins in parallel using the provided `target_partitions` level |+| datafusion.optimizer.repartition_file_scans | false | When set to true, file groups will be repartitioned to achieve maximum parallelism. Currently supported only for Parquet format in which case multiple row groups from the same file may be read concurrently. If false then each row group is read serially, though different files may be read in parallel. |+| datafusion.optimizer.repartition_windows | true | Should DataFusion repartition data using the partitions keys to execute window functions in parallel using the provided `target_partitions` level |+| datafusion.optimizer.repartition_sorts | true | Should DataFusion execute sorts in a per-partition fashion and merge afterwards instead of coalescing first and sorting globally. With this flag is enabled, plans in the form below "SortExec: [a@0 ASC]", " CoalescePartitionsExec", " RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", would turn into the plan below which performs better in multithreaded environments "SortPreservingMergeExec: [a@0 ASC]", " SortExec: [a@0 ASC]", " RepartitionExec: partitioning=RoundRobinBatch(8), input_partitions=1", |+| datafusion.optimizer.skip_failed_rules | true | When set to true, the logical plan optimizer will produce warning messages if any optimization rules produce errors and then proceed to the next rule. When set to false, any rules that produce errors will cause the query to fail |+| datafusion.optimizer.max_passes | 3 | Number of times that the optimizer will attempt to optimize the plan |+| datafusion.optimizer.top_down_join_key_reordering | true | When set to true, the physical plan optimizer will run a top down process to reorder the join keys |+| datafusion.optimizer.prefer_hash_join | true | When set to true, the physical plan optimizer will prefer HashJoin over SortMergeJoin. HashJoin can work more efficiently than SortMergeJoin but consumes more memory |+| datafusion.optimizer.hash_join_single_partition_threshold | 1048576 | The maximum estimated size in bytes for one input side of a HashJoin will be collected into a single partition |+| datafusion.explain.logical_plan_only | false | When set to true, the explain statement will only print logical plans |+| datafusion.explain.physical_plan_only | false | When set to true, the explain statement will only print physical plans |+| datafusion.sql_parser.parse_float_as_decimal | false | When set to true, SQL parser will parse float as decimal type |+| datafusion.sql_parser.enable_ident_normalization | true | When set to true, SQL parser will normalize ident (convert ident to lowercase when not quoted) |