Skip to content

Apache DataFusion SQL Query Engine

chore: upgrade expr and execution crates to rust 2024 edition (#19047)

Tim Saucer91e623bf8406
diff --git a/datafusion/execution/Cargo.toml b/datafusion/execution/Cargo.toml
index f9f7a1bc63..2998e8ab1b 100644
--- a/datafusion/execution/Cargo.toml
+++ b/datafusion/execution/Cargo.toml
@@ -21,7 +21,7 @@ description = "Execution configuration support for DataFusion query engine"
keywords = ["arrow", "query", "sql"]
readme = "README.md"
version = { workspace = true }
-edition = { workspace = true }
+edition = "2024"
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
diff --git a/datafusion/execution/src/cache/cache_manager.rs b/datafusion/execution/src/cache/cache_manager.rs
index 98be9ce34b..d6466a17f5 100644
--- a/datafusion/execution/src/cache/cache_manager.rs
+++ b/datafusion/execution/src/cache/cache_manager.rs
@@ -15,11 +15,11 @@
// specific language governing permissions and limitations
// under the License.
-use crate::cache::cache_unit::DefaultFilesMetadataCache;
use crate::cache::CacheAccessor;
+use crate::cache::cache_unit::DefaultFilesMetadataCache;
use datafusion_common::{Result, Statistics};
-use object_store::path::Path;
use object_store::ObjectMeta;
+use object_store::path::Path;
use std::any::Any;
use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
diff --git a/datafusion/execution/src/cache/cache_unit.rs b/datafusion/execution/src/cache/cache_unit.rs
index 0f9cff54d5..fd9fb2bad3 100644
--- a/datafusion/execution/src/cache/cache_unit.rs
+++ b/datafusion/execution/src/cache/cache_unit.rs
@@ -18,17 +18,17 @@
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
+use crate::cache::CacheAccessor;
use crate::cache::cache_manager::{
FileMetadata, FileMetadataCache, FileMetadataCacheEntry,
};
use crate::cache::lru_queue::LruQueue;
-use crate::cache::CacheAccessor;
use datafusion_common::Statistics;
use dashmap::DashMap;
-use object_store::path::Path;
use object_store::ObjectMeta;
+use object_store::path::Path;
/// Default implementation of [`FileStatisticsCache`]
///
@@ -88,7 +88,7 @@ impl CacheAccessor<Path, Arc<Statistics>> for DefaultFileStatisticsCache {
}
fn remove(&self, k: &Path) -> Option<Arc<Statistics>> {
- self.statistics.remove(k).map(|x| x.1 .1)
+ self.statistics.remove(k).map(|x| x.1.1)
}
fn contains_key(&self, k: &Path) -> bool {
@@ -253,7 +253,7 @@ impl DefaultFilesMetadataCacheState {
fn evict_entries(&mut self) {
while self.memory_used > self.memory_limit {
if let Some(removed) = self.lru_queue.pop() {
- let metadata: Arc<dyn FileMetadata> = removed.1 .1;
+ let metadata: Arc<dyn FileMetadata> = removed.1.1;
self.memory_used -= metadata.memory_size();
} else {
// cache is empty while memory_used > memory_limit, cannot happen
@@ -429,18 +429,18 @@ mod tests {
use std::collections::HashMap;
use std::sync::Arc;
+ use crate::cache::CacheAccessor;
use crate::cache::cache_manager::{
FileMetadata, FileMetadataCache, FileMetadataCacheEntry,
};
use crate::cache::cache_unit::{
DefaultFileStatisticsCache, DefaultFilesMetadataCache, DefaultListFilesCache,
};
- use crate::cache::CacheAccessor;
use arrow::datatypes::{DataType, Field, Schema, TimeUnit};
use chrono::DateTime;
use datafusion_common::Statistics;
- use object_store::path::Path;
use object_store::ObjectMeta;
+ use object_store::path::Path;
#[test]
fn test_statistics_cache() {
diff --git a/datafusion/execution/src/config.rs b/datafusion/execution/src/config.rs
index 3fa602f125..2f78fb5532 100644
--- a/datafusion/execution/src/config.rs
+++ b/datafusion/execution/src/config.rs
@@ -23,8 +23,8 @@ use std::{
};
use datafusion_common::{
- config::{ConfigExtension, ConfigOptions, SpillCompression},
Result, ScalarValue,
+ config::{ConfigExtension, ConfigOptions, SpillCompression},
};
/// Configuration options for [`SessionContext`].
diff --git a/datafusion/execution/src/disk_manager.rs b/datafusion/execution/src/disk_manager.rs
index eb7b643a69..346dda5fd0 100644
--- a/datafusion/execution/src/disk_manager.rs
+++ b/datafusion/execution/src/disk_manager.rs
@@ -18,14 +18,14 @@
//! [`DiskManager`]: Manages files generated during query execution
use datafusion_common::{
- config_err, resources_datafusion_err, resources_err, DataFusionError, Result,
+ DataFusionError, Result, config_err, resources_datafusion_err, resources_err,
};
use log::debug;
use parking_lot::Mutex;
-use rand::{rng, Rng};
+use rand::{Rng, rng};
use std::path::{Path, PathBuf};
-use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;
+use std::sync::atomic::{AtomicU64, Ordering};
use tempfile::{Builder, NamedTempFile, TempDir};
use crate::memory_pool::human_readable_size;
@@ -508,7 +508,10 @@ mod tests {
);
assert!(!manager.tmp_files_enabled());
assert_eq!(
- manager.create_tmp_file("Testing").unwrap_err().strip_backtrace(),
+ manager
+ .create_tmp_file("Testing")
+ .unwrap_err()
+ .strip_backtrace(),
"Resources exhausted: Memory Exhausted while Testing (DiskManager is disabled)",
)
}
diff --git a/datafusion/execution/src/memory_pool/mod.rs b/datafusion/execution/src/memory_pool/mod.rs
index 5a38d24594..5df7ec955d 100644
--- a/datafusion/execution/src/memory_pool/mod.rs
+++ b/datafusion/execution/src/memory_pool/mod.rs
@@ -18,9 +18,9 @@
//! [`MemoryPool`] for memory management during query execution, [`proxy`] for
//! help with allocation accounting.
-use datafusion_common::{internal_err, Result};
+use datafusion_common::{Result, internal_err};
use std::hash::{Hash, Hasher};
-use std::{cmp::Ordering, sync::atomic, sync::Arc};
+use std::{cmp::Ordering, sync::Arc, sync::atomic};
mod pool;
pub mod proxy {
diff --git a/datafusion/execution/src/memory_pool/pool.rs b/datafusion/execution/src/memory_pool/pool.rs
index 9b2a861b75..b4e1649620 100644
--- a/datafusion/execution/src/memory_pool/pool.rs
+++ b/datafusion/execution/src/memory_pool/pool.rs
@@ -16,10 +16,10 @@
// under the License.
use crate::memory_pool::{
- human_readable_size, MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation,
+ MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation, human_readable_size,
};
use datafusion_common::HashMap;
-use datafusion_common::{resources_datafusion_err, DataFusionError, Result};
+use datafusion_common::{DataFusionError, Result, resources_datafusion_err};
use log::debug;
use parking_lot::Mutex;
use std::{
@@ -260,8 +260,13 @@ fn insufficient_capacity_err(
additional: usize,
available: usize,
) -> DataFusionError {
- resources_datafusion_err!("Failed to allocate additional {} for {} with {} already allocated for this reservation - {} remain available for the total pool",
- human_readable_size(additional), reservation.registration.consumer.name, human_readable_size(reservation.size), human_readable_size(available))
+ resources_datafusion_err!(
+ "Failed to allocate additional {} for {} with {} already allocated for this reservation - {} remain available for the total pool",
+ human_readable_size(additional),
+ reservation.registration.consumer.name,
+ human_readable_size(reservation.size),
+ human_readable_size(available)
+ )
}
#[derive(Debug)]
@@ -497,13 +502,15 @@ fn provide_top_memory_consumers_to_error_msg(
error_msg: &str,
top_consumers: &str,
) -> String {
- format!("Additional allocation failed for {consumer_name} with top memory consumers (across reservations) as:\n{top_consumers}\nError: {error_msg}")
+ format!(
+ "Additional allocation failed for {consumer_name} with top memory consumers (across reservations) as:\n{top_consumers}\nError: {error_msg}"
+ )
}
#[cfg(test)]
mod tests {
use super::*;
- use insta::{allow_duplicates, assert_snapshot, Settings};
+ use insta::{Settings, allow_duplicates, assert_snapshot};
use std::sync::Arc;
fn make_settings() -> Settings {
diff --git a/datafusion/execution/src/object_store.rs b/datafusion/execution/src/object_store.rs
index aedee7d444..6af7bf4c3d 100644
--- a/datafusion/execution/src/object_store.rs
+++ b/datafusion/execution/src/object_store.rs
@@ -21,11 +21,11 @@
use dashmap::DashMap;
use datafusion_common::{
- exec_err, internal_datafusion_err, not_impl_err, DataFusionError, Result,
+ DataFusionError, Result, exec_err, internal_datafusion_err, not_impl_err,
};
+use object_store::ObjectStore;
#[cfg(not(target_arch = "wasm32"))]
use object_store::local::LocalFileSystem;
-use object_store::ObjectStore;
use std::sync::Arc;
use url::Url;
@@ -160,7 +160,9 @@ pub trait ObjectStoreRegistry: Send + Sync + std::fmt::Debug + 'static {
/// deregistered store if it existed.
#[allow(unused_variables)]
fn deregister_store(&self, url: &Url) -> Result<Arc<dyn ObjectStore>> {
- not_impl_err!("ObjectStoreRegistry::deregister_store is not implemented for this ObjectStoreRegistry")
+ not_impl_err!(
+ "ObjectStoreRegistry::deregister_store is not implemented for this ObjectStoreRegistry"
+ )
}
/// Get a suitable store for the provided URL. For example:
@@ -290,17 +292,29 @@ mod tests {
assert_eq!(err.strip_backtrace(), "External error: invalid port number");
let err = ObjectStoreUrl::parse("s3://bucket?").unwrap_err();
- assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?");
+ assert_eq!(
+ err.strip_backtrace(),
+ "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?"
+ );
let err = ObjectStoreUrl::parse("s3://bucket?foo=bar").unwrap_err();
- assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar");
+ assert_eq!(
+ err.strip_backtrace(),
+ "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar"
+ );
let err = ObjectStoreUrl::parse("s3://host:123/foo").unwrap_err();
- assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
+ assert_eq!(
+ err.strip_backtrace(),
+ "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"
+ );
let err =
ObjectStoreUrl::parse("s3://username:password@host:123/foo").unwrap_err();
- assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
+ assert_eq!(
+ err.strip_backtrace(),
+ "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"
+ );
}
#[test]
diff --git a/datafusion/execution/src/runtime_env.rs b/datafusion/execution/src/runtime_env.rs
index abcbe897d2..fc993d2865 100644
--- a/datafusion/execution/src/runtime_env.rs
+++ b/datafusion/execution/src/runtime_env.rs
@@ -31,7 +31,7 @@ use crate::{
use crate::cache::cache_manager::{CacheManager, CacheManagerConfig};
#[cfg(feature = "parquet_encryption")]
use crate::parquet_encryption::{EncryptionFactory, EncryptionFactoryRegistry};
-use datafusion_common::{config::ConfigEntry, Result};
+use datafusion_common::{Result, config::ConfigEntry};
use object_store::ObjectStore;
use std::path::PathBuf;
use std::sync::Arc;
@@ -122,7 +122,7 @@ fn create_runtime_config_entries(
key: "datafusion.runtime.metadata_cache_limit".to_string(),
value: metadata_cache_limit,
description: "Maximum memory to use for file metadata cache such as Parquet metadata. Supports suffixes K (kilobytes), M (megabytes), and G (gigabytes). Example: '2G' for 2 gigabytes.",
- }
+ },
]
}
diff --git a/datafusion/execution/src/task.rs b/datafusion/execution/src/task.rs
index c2a6cfe2c8..8b14095632 100644
--- a/datafusion/execution/src/task.rs
+++ b/datafusion/execution/src/task.rs
@@ -19,7 +19,7 @@ use crate::{
config::SessionConfig, memory_pool::MemoryPool, registry::FunctionRegistry,
runtime_env::RuntimeEnv,
};
-use datafusion_common::{internal_datafusion_err, plan_datafusion_err, Result};
+use datafusion_common::{Result, internal_datafusion_err, plan_datafusion_err};
use datafusion_expr::planner::ExprPlanner;
use datafusion_expr::{AggregateUDF, ScalarUDF, WindowUDF};
use std::collections::HashSet;
diff --git a/datafusion/expr/Cargo.toml b/datafusion/expr/Cargo.toml
index 75aa59595b..37de339605 100644
--- a/datafusion/expr/Cargo.toml
+++ b/datafusion/expr/Cargo.toml
@@ -21,7 +21,7 @@ description = "Logical plan and expression representation for DataFusion query e
keywords = ["datafusion", "logical", "plan", "expressions"]
readme = "README.md"
version = { workspace = true }
-edition = { workspace = true }
+edition = "2024"
homepage = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
diff --git a/datafusion/expr/src/arguments.rs b/datafusion/expr/src/arguments.rs
index 5653993db9..6bd6e57236 100644
--- a/datafusion/expr/src/arguments.rs
+++ b/datafusion/expr/src/arguments.rs
@@ -18,7 +18,7 @@
//! Argument resolution logic for named function parameters
use crate::Expr;
-use datafusion_common::{plan_err, Result};
+use datafusion_common::{Result, plan_err};
use std::collections::HashMap;
/// Resolves function arguments, handling named and positional notation.
@@ -229,10 +229,12 @@ mod tests {
let result = resolve_function_arguments(&param_names, args, arg_names);
assert!(result.is_err());
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("Positional argument"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("Positional argument")
+ );
}
#[test]
@@ -245,10 +247,12 @@ mod tests {
let result = resolve_function_arguments(&param_names, args, arg_names);
assert!(result.is_err());
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("Unknown parameter"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("Unknown parameter")
+ );
}
#[test]
@@ -261,10 +265,12 @@ mod tests {
let result = resolve_function_arguments(&param_names, args, arg_names);
assert!(result.is_err());
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("specified multiple times"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("specified multiple times")
+ );
}
#[test]
@@ -277,9 +283,11 @@ mod tests {
let result = resolve_function_arguments(&param_names, args, arg_names);
assert!(result.is_err());
- assert!(result
- .unwrap_err()
- .to_string()
- .contains("Missing required parameter"));
+ assert!(
+ result
+ .unwrap_err()
+ .to_string()
+ .contains("Missing required parameter")
+ );
}
}
diff --git a/datafusion/expr/src/async_udf.rs b/datafusion/expr/src/async_udf.rs
index 561ef1dc15..8afdfda68d 100644
--- a/datafusion/expr/src/async_udf.rs
+++ b/datafusion/expr/src/async_udf.rs
@@ -146,8 +146,8 @@ mod tests {
use datafusion_expr_common::{columnar_value::ColumnarValue, signature::Signature};
use crate::{
- async_udf::{AsyncScalarUDF, AsyncScalarUDFImpl},
ScalarFunctionArgs, ScalarUDFImpl,
+ async_udf::{AsyncScalarUDF, AsyncScalarUDFImpl},
};
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
diff --git a/datafusion/expr/src/conditional_expressions.rs b/datafusion/expr/src/conditional_expressions.rs
index d02f522910..10a9fd6948 100644
--- a/datafusion/expr/src/conditional_expressions.rs
+++ b/datafusion/expr/src/conditional_expressions.rs
@@ -17,9 +17,9 @@
//! Conditional expressions
use crate::expr::Case;
-use crate::{expr_schema::ExprSchemable, Expr};
+use crate::{Expr, expr_schema::ExprSchemable};
use arrow::datatypes::DataType;
-use datafusion_common::{plan_err, DFSchema, HashSet, Result};
+use datafusion_common::{DFSchema, HashSet, Result, plan_err};
use itertools::Itertools as _;
/// Helper struct for building [Expr::Case]
diff --git a/datafusion/expr/src/execution_props.rs b/datafusion/expr/src/execution_props.rs
index acfcc61b7e..20d8f82bf4 100644
--- a/datafusion/expr/src/execution_props.rs
+++ b/datafusion/expr/src/execution_props.rs
@@ -17,9 +17,9 @@
use crate::var_provider::{VarProvider, VarType};
use chrono::{DateTime, TimeZone, Utc};
+use datafusion_common::HashMap;
use datafusion_common::alias::AliasGenerator;
use datafusion_common::config::ConfigOptions;
-use datafusion_common::HashMap;
use std::sync::Arc;
/// Holds per-query execution properties and data (such as statement
@@ -125,6 +125,9 @@ mod test {
#[test]
fn debug() {
let props = ExecutionProps::new();
- assert_eq!("ExecutionProps { query_execution_start_time: 1970-01-01T00:00:00Z, alias_generator: AliasGenerator { next_id: 1 }, config_options: None, var_providers: None }", format!("{props:?}"));
+ assert_eq!(
+ "ExecutionProps { query_execution_start_time: 1970-01-01T00:00:00Z, alias_generator: AliasGenerator { next_id: 1 }, config_options: None, var_providers: None }",
+ format!("{props:?}")
+ );
}
}
diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs
index 714925dadc..a595b59355 100644
--- a/datafusion/expr/src/expr.rs
+++ b/datafusion/expr/src/expr.rs
@@ -41,8 +41,8 @@ use datafusion_common::{
use datafusion_functions_window_common::field::WindowUDFFieldArgs;
#[cfg(feature = "sql")]
use sqlparser::ast::{
- display_comma_separated, ExceptSelectItem, ExcludeSelectItem, IlikeSelectItem,
- RenameSelectItem, ReplaceSelectElement,
+ ExceptSelectItem, ExcludeSelectItem, IlikeSelectItem, RenameSelectItem,
+ ReplaceSelectElement, display_comma_separated,
};
// Moved in 51.0.0 to datafusion_common
@@ -2681,24 +2681,23 @@ impl HashNode for Expr {
// Modifies expr to match the DataType, metadata, and nullability of other if it is
// a placeholder with previously unspecified type information (i.e., most placeholders)
fn rewrite_placeholder(expr: &mut Expr, other: &Expr, schema: &DFSchema) -> Result<()> {
- if let Expr::Placeholder(Placeholder { id: _, field }) = expr {
- if field.is_none() {
- let other_field = other.to_field(schema);
- match other_field {
- Err(e) => {
- Err(e.context(format!(
- "Can not find type of {other} needed to infer type of {expr}"
- )))?;
- }
- Ok((_, other_field)) => {
- // We can't infer the nullability of the future parameter that might
- // be bound, so ensure this is set to true
- *field =
- Some(other_field.as_ref().clone().with_nullable(true).into());
- }
+ if let Expr::Placeholder(Placeholder { id: _, field }) = expr
+ && field.is_none()
+ {
+ let other_field = other.to_field(schema);
+ match other_field {
+ Err(e) => {
+ Err(e.context(format!(
+ "Can not find type of {other} needed to infer type of {expr}"
+ )))?;
+ }
+ Ok((_, other_field)) => {
+ // We can't infer the nullability of the future parameter that might
+ // be bound, so ensure this is set to true
+ *field = Some(other_field.as_ref().clone().with_nullable(true).into());
}
- };
- }
+ }
+ };
Ok(())
}
@@ -3511,8 +3510,8 @@ pub fn physical_name(expr: &Expr) -> Result<String> {
mod test {
use crate::expr_fn::col;
use crate::{
- case, lit, placeholder, qualified_wildcard, wildcard, wildcard_with_options,
- ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Volatility,
+ ColumnarValue, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl, Volatility, case,
+ lit, placeholder, qualified_wildcard, wildcard, wildcard_with_options,
};
use arrow::datatypes::{Field, Schema};
use sqlparser::ast;
@@ -3628,11 +3627,11 @@ mod test {
#[test]
fn infer_placeholder_with_metadata() {
// name == $1, where name is a non-nullable string
- let schema =
- Arc::new(Schema::new(vec![Field::new("name", DataType::Utf8, false)
- .with_metadata(
- [("some_key".to_string(), "some_value".to_string())].into(),
- )]));
+ let schema = Arc::new(Schema::new(vec![
+ Field::new("name", DataType::Utf8, false).with_metadata(
+ [("some_key".to_string(), "some_value".to_string())].into(),
+ ),
+ ]));
let df_schema = DFSchema::try_from(schema).unwrap();
let expr = binary_expr(col("name"), Operator::Eq, placeholder("$1"));
diff --git a/datafusion/expr/src/expr_fn.rs b/datafusion/expr/src/expr_fn.rs
index 94d8009ce8..4254602d7c 100644
--- a/datafusion/expr/src/expr_fn.rs
+++ b/datafusion/expr/src/expr_fn.rs
@@ -28,9 +28,9 @@ use crate::function::{
use crate::ptr_eq::PtrEq;
use crate::select_expr::SelectExpr;
use crate::{
- conditional_expressions::CaseBuilder, expr::Sort, logical_plan::Subquery,
AggregateUDF, Expr, LimitEffect, LogicalPlan, Operator, PartitionEvaluator,
ScalarFunctionArgs, ScalarFunctionImplementation, ScalarUDF, Signature, Volatility,
+ conditional_expressions::CaseBuilder, expr::Sort, logical_plan::Subquery,
};
use crate::{
AggregateUDFImpl, ColumnarValue, ScalarUDFImpl, WindowFrame, WindowUDF, WindowUDFImpl,
@@ -39,7 +39,7 @@ use arrow::compute::kernels::cast_utils::{
parse_interval_day_time, parse_interval_month_day_nano, parse_interval_year_month,
};
use arrow::datatypes::{DataType, Field, FieldRef};
-use datafusion_common::{plan_err, Column, Result, ScalarValue, Spans, TableReference};
+use datafusion_common::{Column, Result, ScalarValue, Spans, TableReference, plan_err};
use datafusion_functions_window_common::field::WindowUDFFieldArgs;
use datafusion_functions_window_common::partition::PartitionEvaluatorArgs;
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
diff --git a/datafusion/expr/src/expr_rewriter/guarantees.rs b/datafusion/expr/src/expr_rewriter/guarantees.rs
index b8589a17df..30c79f6529 100644
--- a/datafusion/expr/src/expr_rewriter/guarantees.rs
+++ b/datafusion/expr/src/expr_rewriter/guarantees.rs
@@ -17,7 +17,7 @@
//! Rewrite expressions based on external expression value range guarantees.
-use crate::{expr::InList, lit, Between, BinaryExpr, Expr};
+use crate::{Between, BinaryExpr, Expr, expr::InList, lit};
use datafusion_common::tree_node::{Transformed, TreeNode, TreeNodeRewriter};
use datafusion_common::{DataFusionError, HashMap, Result, ScalarValue};
use datafusion_expr_common::interval_arithmetic::{Interval, NullableInterval};
@@ -102,10 +102,10 @@ fn rewrite_expr(
guarantees: &HashMap<&Expr, &NullableInterval>,
) -> Result<Transformed<Expr>> {
// If an expression collapses to a single value, replace it with a literal
- if let Some(interval) = guarantees.get(&expr) {
- if let Some(value) = interval.single_value() {
- return Ok(Transformed::yes(lit(value)));
- }
+ if let Some(interval) = guarantees.get(&expr)
+ && let Some(value) = interval.single_value()
+ {
+ return Ok(Transformed::yes(lit(value)));
}
let result = match expr {
@@ -302,9 +302,9 @@ fn rewrite_inlist(
mod tests {
use super::*;
- use crate::{col, Operator};
- use datafusion_common::tree_node::TransformedResult;
+ use crate::{Operator, col};
use datafusion_common::ScalarValue;
+ use datafusion_common::tree_node::TransformedResult;
#[test]
fn test_not_null_guarantee() {
diff --git a/datafusion/expr/src/expr_rewriter/mod.rs b/datafusion/expr/src/expr_rewriter/mod.rs
index 31759f1cc9..f5f49c643c 100644
--- a/datafusion/expr/src/expr_rewriter/mod.rs
+++ b/datafusion/expr/src/expr_rewriter/mod.rs
@@ -26,15 +26,15 @@ use crate::expr::{Alias, Sort, Unnest};
use crate::logical_plan::Projection;
use crate::{Expr, ExprSchemable, LogicalPlan, LogicalPlanBuilder};
+use datafusion_common::TableReference;
use datafusion_common::config::ConfigOptions;
use datafusion_common::tree_node::{Transformed, TransformedResult, TreeNode};
-use datafusion_common::TableReference;
use datafusion_common::{Column, DFSchema, Result};
mod guarantees;
+pub use guarantees::GuaranteeRewriter;
pub use guarantees::rewrite_with_guarantees;
pub use guarantees::rewrite_with_guarantees_map;
-pub use guarantees::GuaranteeRewriter;
mod order_by;
pub use order_by::rewrite_sort_cols_by_aggs;
@@ -360,10 +360,10 @@ mod test {
use super::*;
use crate::literal::lit_with_metadata;
- use crate::{col, lit, Cast};
+ use crate::{Cast, col, lit};
use arrow::datatypes::{DataType, Field, Schema};
- use datafusion_common::tree_node::TreeNodeRewriter;
use datafusion_common::ScalarValue;
+ use datafusion_common::tree_node::TreeNodeRewriter;
#[derive(Default)]
struct RecordingRewriter {
diff --git a/datafusion/expr/src/expr_rewriter/order_by.rs b/datafusion/expr/src/expr_rewriter/order_by.rs
index c21c6e6222..ec22be5254 100644
--- a/datafusion/expr/src/expr_rewriter/order_by.rs
+++ b/datafusion/expr/src/expr_rewriter/order_by.rs
@@ -19,7 +19,7 @@
use crate::expr::Alias;
use crate::expr_rewriter::normalize_col;
-use crate::{expr::Sort, Cast, Expr, LogicalPlan, TryCast};
+use crate::{Cast, Expr, LogicalPlan, TryCast, expr::Sort};
use datafusion_common::tree_node::{
Transformed, TransformedResult, TreeNode, TreeNodeRecursion,
@@ -152,8 +152,8 @@ mod test {
use arrow::datatypes::{DataType, Field, Schema};
use crate::{
- cast, col, lit, logical_plan::builder::LogicalTableSource, try_cast,
- LogicalPlanBuilder,
+ LogicalPlanBuilder, cast, col, lit, logical_plan::builder::LogicalTableSource,
+ try_cast,
};
use super::*;
diff --git a/datafusion/expr/src/expr_schema.rs b/datafusion/expr/src/expr_schema.rs
index 993b806fde..0d89531065 100644
--- a/datafusion/expr/src/expr_schema.rs
+++ b/datafusion/expr/src/expr_schema.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-use super::{predicate_bounds, Between, Expr, Like};
+use super::{Between, Expr, Like, predicate_bounds};
use crate::expr::{
AggregateFunction, AggregateFunctionParams, Alias, BinaryExpr, Cast, InList,
InSubquery, Placeholder, ScalarFunction, TryCast, Unnest, WindowFunction,
@@ -25,14 +25,14 @@ use crate::type_coercion::functions::{
data_types_with_scalar_udf, fields_with_aggregate_udf, fields_with_window_udf,
};
use crate::udf::ReturnFieldArgs;
-use crate::{utils, LogicalPlan, Projection, Subquery, WindowFunctionDefinition};
+use crate::{LogicalPlan, Projection, Subquery, WindowFunctionDefinition, utils};
use arrow::compute::can_cast_types;
use arrow::datatypes::{DataType, Field, FieldRef};
use datafusion_common::datatype::FieldExt;
use datafusion_common::metadata::FieldMetadata;
use datafusion_common::{
- not_impl_err, plan_datafusion_err, plan_err, Column, DataFusionError, ExprSchema,
- Result, ScalarValue, Spans, TableReference,
+ Column, DataFusionError, ExprSchema, Result, ScalarValue, Spans, TableReference,
+ not_impl_err, plan_datafusion_err, plan_err,
};
use datafusion_expr_common::type_coercion::binary::BinaryTypeCoercer;
use datafusion_functions_window_common::field::WindowUDFFieldArgs;
@@ -64,7 +64,7 @@ pub trait ExprSchemable {
note = "Use `to_field().1.is_nullable` and `to_field().1.data_type()` directly instead"
)]
fn data_type_and_nullable(&self, schema: &dyn ExprSchema)
- -> Result<(DataType, bool)>;
+ -> Result<(DataType, bool)>;
}
impl ExprSchemable for Expr {
@@ -208,11 +208,7 @@ impl ExprSchemable for Expr {
Expr::ScalarSubquery(subquery) => {
Ok(subquery.subquery.schema().field(0).data_type().clone())
}
- Expr::BinaryExpr(BinaryExpr {
- ref left,
- ref right,
- ref op,
- }) => BinaryTypeCoercer::new(
+ Expr::BinaryExpr(BinaryExpr { left, right, op }) => BinaryTypeCoercer::new(
&left.get_type(schema)?,
op,
&right.get_type(schema)?,
@@ -388,11 +384,9 @@ impl ExprSchemable for Expr {
Expr::ScalarSubquery(subquery) => {
Ok(subquery.subquery.schema().field(0).is_nullable())
}
- Expr::BinaryExpr(BinaryExpr {
- ref left,
- ref right,
- ..
- }) => Ok(left.nullable(input_schema)? || right.nullable(input_schema)?),
+ Expr::BinaryExpr(BinaryExpr { left, right, .. }) => {
+ Ok(left.nullable(input_schema)? || right.nullable(input_schema)?)
+ }
Expr::Like(Like { expr, pattern, .. })
| Expr::SimilarTo(Like { expr, pattern, .. }) => {
Ok(expr.nullable(input_schema)? || pattern.nullable(input_schema)?)
@@ -530,11 +524,7 @@ impl ExprSchemable for Expr {
Expr::ScalarSubquery(subquery) => {
Ok(Arc::clone(&subquery.subquery.schema().fields()[0]))
}
- Expr::BinaryExpr(BinaryExpr {
- ref left,
- ref right,
- ref op,
- }) => {
+ Expr::BinaryExpr(BinaryExpr { left, right, op }) => {
let (left_field, right_field) =
(left.to_field(schema)?.1, right.to_field(schema)?.1);
@@ -844,7 +834,7 @@ mod tests {
use super::*;
use crate::{and, col, lit, not, or, out_ref_col_with_metadata, when};
- use datafusion_common::{assert_or_internal_err, DFSchema, ScalarValue};
+ use datafusion_common::{DFSchema, ScalarValue, assert_or_internal_err};
macro_rules! test_is_expr_nullable {
($EXPR_TYPE:ident) => {{
@@ -857,9 +847,10 @@ mod tests {
fn expr_schema_nullability() {
let expr = col("foo").eq(lit(1));
assert!(!expr.nullable(&MockExprSchema::new()).unwrap());
- assert!(expr
- .nullable(&MockExprSchema::new().with_nullable(true))
- .unwrap());
+ assert!(
+ expr.nullable(&MockExprSchema::new().with_nullable(true))
+ .unwrap()
+ );
test_is_expr_nullable!(is_null);
test_is_expr_nullable!(is_not_null);
@@ -1038,9 +1029,10 @@ mod tests {
assert!(!expr.nullable(&get_schema(false)).unwrap());
assert!(expr.nullable(&get_schema(true)).unwrap());
// Testing nullable() returns an error.
- assert!(expr
- .nullable(&get_schema(false).with_error_on_nullable(true))
- .is_err());
+ assert!(
+ expr.nullable(&get_schema(false).with_error_on_nullable(true))
+ .is_err()
+ );
let null = lit(ScalarValue::Int32(None));
let expr = col("foo").in_list(vec![null, lit(1)], false);
diff --git a/datafusion/expr/src/lib.rs b/datafusion/expr/src/lib.rs
index d71b3230d9..ec4942e9a8 100644
--- a/datafusion/expr/src/lib.rs
+++ b/datafusion/expr/src/lib.rs
@@ -83,16 +83,16 @@ pub mod window_frame;
pub mod window_state;
pub use datafusion_doc::{
- aggregate_doc_sections, scalar_doc_sections, window_doc_sections, DocSection,
- Documentation, DocumentationBuilder,
+ DocSection, Documentation, DocumentationBuilder, aggregate_doc_sections,
+ scalar_doc_sections, window_doc_sections,
};
pub use datafusion_expr_common::accumulator::Accumulator;
pub use datafusion_expr_common::columnar_value::ColumnarValue;
pub use datafusion_expr_common::groups_accumulator::{EmitTo, GroupsAccumulator};
pub use datafusion_expr_common::operator::Operator;
pub use datafusion_expr_common::signature::{
- ArrayFunctionArgument, ArrayFunctionSignature, Coercion, Signature, TypeSignature,
- TypeSignatureClass, Volatility, TIMEZONE_WILDCARD,
+ ArrayFunctionArgument, ArrayFunctionSignature, Coercion, Signature,
+ TIMEZONE_WILDCARD, TypeSignature, TypeSignatureClass, Volatility,
};
pub use datafusion_expr_common::type_coercion::binary;
pub use expr::{
@@ -106,7 +106,7 @@ pub use function::{
ScalarFunctionImplementation, StateTypeFunction,
};
pub use literal::{
- lit, lit_timestamp_nano, lit_with_metadata, Literal, TimestampLiteral,
+ Literal, TimestampLiteral, lit, lit_timestamp_nano, lit_with_metadata,
};
pub use logical_plan::*;
pub use partition_evaluator::PartitionEvaluator;
@@ -114,10 +114,10 @@ pub use partition_evaluator::PartitionEvaluator;
pub use sqlparser;
pub use table_source::{TableProviderFilterPushDown, TableSource, TableType};
pub use udaf::{
+ AggregateUDF, AggregateUDFImpl, ReversedUDAF, SetMonotonicity, StatisticsArgs,
udaf_default_display_name, udaf_default_human_display, udaf_default_return_field,
udaf_default_schema_name, udaf_default_window_function_display_name,
- udaf_default_window_function_schema_name, AggregateUDF, AggregateUDFImpl,
- ReversedUDAF, SetMonotonicity, StatisticsArgs,
+ udaf_default_window_function_schema_name,
};
pub use udf::{ReturnFieldArgs, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl};
pub use udwf::{LimitEffect, ReversedUDWF, WindowUDF, WindowUDFImpl};
diff --git a/datafusion/expr/src/literal.rs b/datafusion/expr/src/literal.rs
index 09d8e9bb58..2e2980d607 100644
--- a/datafusion/expr/src/literal.rs
+++ b/datafusion/expr/src/literal.rs
@@ -18,7 +18,7 @@
//! Literal module contains foundational types that are used to represent literals in DataFusion.
use crate::Expr;
-use datafusion_common::{metadata::FieldMetadata, ScalarValue};
+use datafusion_common::{ScalarValue, metadata::FieldMetadata};
/// Create a literal expression
#[expect(clippy::needless_pass_by_value)]
diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs
index b291717d1d..835f99c274 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -44,8 +44,8 @@ use crate::utils::{
group_window_expr_by_sort_keys,
};
use crate::{
- and, binary_expr, lit, DmlStatement, ExplainOption, Expr, ExprSchemable, Operator,
- RecursiveQuery, Statement, TableProviderFilterPushDown, TableSource, WriteOp,
+ DmlStatement, ExplainOption, Expr, ExprSchemable, Operator, RecursiveQuery,
+ Statement, TableProviderFilterPushDown, TableSource, WriteOp, and, binary_expr, lit,
};
use super::dml::InsertOp;
@@ -55,9 +55,10 @@ use datafusion_common::display::ToStringifiedPlan;
use datafusion_common::file_options::file_type::FileType;
use datafusion_common::metadata::FieldMetadata;
use datafusion_common::{
- exec_err, get_target_functional_dependencies, internal_datafusion_err,
- plan_datafusion_err, plan_err, Column, Constraints, DFSchema, DFSchemaRef,
- NullEquality, Result, ScalarValue, TableReference, ToDFSchema, UnnestOptions,
+ Column, Constraints, DFSchema, DFSchemaRef, NullEquality, Result, ScalarValue,
+ TableReference, ToDFSchema, UnnestOptions, exec_err,
+ get_target_functional_dependencies, internal_datafusion_err, plan_datafusion_err,
+ plan_err,
};
use datafusion_expr_common::type_coercion::binary::type_union_resolution;
@@ -185,7 +186,8 @@ impl LogicalPlanBuilder {
if static_fields_len != recursive_fields_len {
return plan_err!(
"Non-recursive term and recursive term must have the same number of columns ({} != {})",
- static_fields_len, recursive_fields_len
+ static_fields_len,
+ recursive_fields_len
);
}
// Ensure that the recursive term has the same field types as the static term
@@ -306,7 +308,11 @@ impl LogicalPlanBuilder {
let metadata = value.metadata(&schema)?;
if let Some(ref cm) = common_metadata {
if &metadata != cm {
- return plan_err!("Inconsistent metadata across values list at row {i} column {j}. Was {:?} but found {:?}", cm, metadata);
+ return plan_err!(
+ "Inconsistent metadata across values list at row {i} column {j}. Was {:?} but found {:?}",
+ cm,
+ metadata
+ );
}
} else {
common_metadata = Some(metadata.clone());
@@ -320,7 +326,9 @@ impl LogicalPlanBuilder {
// get common type of each column values.
let data_types = vec![prev_type.clone(), data_type.clone()];
let Some(new_type) = type_union_resolution(&data_types) else {
- return plan_err!("Inconsistent data type across values list at row {i} column {j}. Was {prev_type} but found {data_type}");
+ return plan_err!(
+ "Inconsistent data type across values list at row {i} column {j}. Was {prev_type} but found {data_type}"
+ );
};
common_type = Some(new_type);
} else {
@@ -507,29 +515,27 @@ impl LogicalPlanBuilder {
TableScan::try_new(table_name, table_source, projection, filters, fetch)?;
// Inline TableScan
- if table_scan.filters.is_empty() {
- if let Some(p) = table_scan.source.get_logical_plan() {
- let sub_plan = p.into_owned();
-
- if let Some(proj) = table_scan.projection {
- let projection_exprs = proj
- .into_iter()
- .map(|i| {
- Expr::Column(Column::from(
- sub_plan.schema().qualified_field(i),
- ))
- })
- .collect::<Vec<_>>();
- return Self::new(sub_plan)
- .project(projection_exprs)?
- .alias(table_scan.table_name);
- }
+ if table_scan.filters.is_empty()
+ && let Some(p) = table_scan.source.get_logical_plan()
+ {
+ let sub_plan = p.into_owned();
- // Ensures that the reference to the inlined table remains the
- // same, meaning we don't have to change any of the parent nodes
- // that reference this table.
- return Self::new(sub_plan).alias(table_scan.table_name);
+ if let Some(proj) = table_scan.projection {
+ let projection_exprs = proj
+ .into_iter()
+ .map(|i| {
+ Expr::Column(Column::from(sub_plan.schema().qualified_field(i)))
+ })
+ .collect::<Vec<_>>();
+ return Self::new(sub_plan)
+ .project(projection_exprs)?
+ .alias(table_scan.table_name);
}
+
+ // Ensures that the reference to the inlined table remains the
+ // same, meaning we don't have to change any of the parent nodes
+ // that reference this table.
+ return Self::new(sub_plan).alias(table_scan.table_name);
}
Ok(Self::new(LogicalPlan::TableScan(table_scan)))
@@ -765,7 +771,9 @@ impl LogicalPlanBuilder {
.map(|col| col.flat_name())
.collect::<String>();
- plan_err!("For SELECT DISTINCT, ORDER BY expressions {missing_col_names} must appear in select list")
+ plan_err!(
+ "For SELECT DISTINCT, ORDER BY expressions {missing_col_names} must appear in select list"
+ )
}
/// Apply a sort by provided expressions with default direction
@@ -1920,15 +1928,14 @@ fn replace_columns(
replace: &PlannedReplaceSelectItem,
) -> Result<Vec<Expr>> {
for expr in exprs.iter_mut() {
- if let Expr::Column(Column { name, .. }) = expr {
- if let Some((_, new_expr)) = replace
+ if let Expr::Column(Column { name, .. }) = expr
+ && let Some((_, new_expr)) = replace
.items()
.iter()
.zip(replace.expressions().iter())
.find(|(item, _)| item.column_name.value == *name)
- {
- *expr = new_expr.clone().alias(name.clone())
- }
+ {
+ *expr = new_expr.clone().alias(name.clone())
}
}
Ok(exprs)
@@ -2822,11 +2829,13 @@ mod tests {
.into_iter()
.collect();
let metadata2 = FieldMetadata::from(metadata2);
- assert!(LogicalPlanBuilder::values(vec![
- vec![lit_with_metadata(1, Some(metadata.clone()))],
- vec![lit_with_metadata(2, Some(metadata2.clone()))],
- ])
- .is_err());
+ assert!(
+ LogicalPlanBuilder::values(vec![
+ vec![lit_with_metadata(1, Some(metadata.clone()))],
+ vec![lit_with_metadata(2, Some(metadata2.clone()))],
+ ])
+ .is_err()
+ );
Ok(())
}
diff --git a/datafusion/expr/src/logical_plan/ddl.rs b/datafusion/expr/src/logical_plan/ddl.rs
index 74fe7a2d00..ac8ebea17f 100644
--- a/datafusion/expr/src/logical_plan/ddl.rs
+++ b/datafusion/expr/src/logical_plan/ddl.rs
@@ -132,7 +132,7 @@ impl DdlStatement {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
DdlStatement::CreateExternalTable(CreateExternalTable {
- ref name,
+ name,
constraints,
..
}) => {
@@ -186,7 +186,10 @@ impl DdlStatement {
cascade,
..
}) => {
- write!(f, "DropCatalogSchema: {name:?} if not exist:={if_exists} cascade:={cascade}")
+ write!(
+ f,
+ "DropCatalogSchema: {name:?} if not exist:={if_exists} cascade:={cascade}"
+ )
}
DdlStatement::CreateFunction(CreateFunction { name, .. }) => {
write!(f, "CreateFunction: name {name:?}")
diff --git a/datafusion/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rs
index b601263355..480974b055 100644
--- a/datafusion/expr/src/logical_plan/display.rs
+++ b/datafusion/expr/src/logical_plan/display.rs
@@ -21,17 +21,17 @@ use std::collections::HashMap;
use std::fmt;
use crate::{
- expr_vec_fmt, Aggregate, DescribeTable, Distinct, DistinctOn, DmlStatement, Expr,
- Filter, Join, Limit, LogicalPlan, Partitioning, Projection, RecursiveQuery,
- Repartition, Sort, Subquery, SubqueryAlias, TableProviderFilterPushDown, TableScan,
- Unnest, Values, Window,
+ Aggregate, DescribeTable, Distinct, DistinctOn, DmlStatement, Expr, Filter, Join,
+ Limit, LogicalPlan, Partitioning, Projection, RecursiveQuery, Repartition, Sort,
+ Subquery, SubqueryAlias, TableProviderFilterPushDown, TableScan, Unnest, Values,
+ Window, expr_vec_fmt,
};
use crate::dml::CopyTo;
use arrow::datatypes::Schema;
use datafusion_common::display::GraphvizBuilder;
use datafusion_common::tree_node::{TreeNodeRecursion, TreeNodeVisitor};
-use datafusion_common::{internal_datafusion_err, Column, DataFusionError};
+use datafusion_common::{Column, DataFusionError, internal_datafusion_err};
use serde_json::json;
/// Formats plans with a single line per node. For example:
@@ -319,7 +319,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
"Is Distinct": is_distinct,
})
}
- LogicalPlan::Values(Values { ref values, .. }) => {
+ LogicalPlan::Values(Values { values, .. }) => {
let str_values = values
.iter()
// limit to only 5 values to avoid horrible display
@@ -344,10 +344,10 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
})
}
LogicalPlan::TableScan(TableScan {
- ref source,
- ref table_name,
- ref filters,
- ref fetch,
+ source,
+ table_name,
+ filters,
+ fetch,
..
}) => {
let mut object = json!({
@@ -403,7 +403,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
object
}
- LogicalPlan::Projection(Projection { ref expr, .. }) => {
+ LogicalPlan::Projection(Projection { expr, .. }) => {
json!({
"Node Type": "Projection",
"Expressions": expr.iter().map(|e| e.to_string()).collect::<Vec<_>>()
@@ -443,25 +443,22 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
})
}
LogicalPlan::Filter(Filter {
- predicate: ref expr,
- ..
+ predicate: expr, ..
}) => {
json!({
"Node Type": "Filter",
"Condition": format!("{}", expr)
})
}
- LogicalPlan::Window(Window {
- ref window_expr, ..
- }) => {
+ LogicalPlan::Window(Window { window_expr, .. }) => {
json!({
"Node Type": "WindowAggr",
"Expressions": expr_vec_fmt!(window_expr)
})
}
LogicalPlan::Aggregate(Aggregate {
- ref group_expr,
- ref aggr_expr,
+ group_expr,
+ aggr_expr,
..
}) => {
json!({
@@ -483,7 +480,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
object
}
LogicalPlan::Join(Join {
- on: ref keys,
+ on: keys,
filter,
join_constraint,
join_type,
@@ -534,11 +531,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
})
}
},
- LogicalPlan::Limit(Limit {
- ref skip,
- ref fetch,
- ..
- }) => {
+ LogicalPlan::Limit(Limit { skip, fetch, .. }) => {
let mut object = serde_json::json!(
{
"Node Type": "Limit",
@@ -557,7 +550,7 @@ impl<'a, 'b> PgJsonVisitor<'a, 'b> {
"Node Type": "Subquery"
})
}
- LogicalPlan::SubqueryAlias(SubqueryAlias { ref alias, .. }) => {
+ LogicalPlan::SubqueryAlias(SubqueryAlias { alias, .. }) => {
json!({
"Node Type": "Subquery",
"Alias": alias.table(),
diff --git a/datafusion/expr/src/logical_plan/invariants.rs b/datafusion/expr/src/logical_plan/invariants.rs
index 1c2c8a2a93..762491a255 100644
--- a/datafusion/expr/src/logical_plan/invariants.rs
+++ b/datafusion/expr/src/logical_plan/invariants.rs
@@ -16,16 +16,15 @@
// under the License.
use datafusion_common::{
- assert_or_internal_err, plan_err,
+ DFSchemaRef, Result, assert_or_internal_err, plan_err,
tree_node::{TreeNode, TreeNodeRecursion},
- DFSchemaRef, Result,
};
use crate::{
+ Aggregate, Expr, Filter, Join, JoinType, LogicalPlan, Window,
expr::{Exists, InSubquery},
expr_rewriter::strip_outer_reference,
utils::{collect_subquery_cols, split_conjunction},
- Aggregate, Expr, Filter, Join, JoinType, LogicalPlan, Window,
};
use super::Extension;
@@ -198,9 +197,12 @@ pub fn check_subquery_expr(
}
}?;
match outer_plan {
- LogicalPlan::Projection(_)
- | LogicalPlan::Filter(_) => Ok(()),
- LogicalPlan::Aggregate(Aggregate { group_expr, aggr_expr, .. }) => {
+ LogicalPlan::Projection(_) | LogicalPlan::Filter(_) => Ok(()),
+ LogicalPlan::Aggregate(Aggregate {
+ group_expr,
+ aggr_expr,
+ ..
+ }) => {
if group_expr.contains(expr) && !aggr_expr.contains(expr) {
// TODO revisit this validation logic
plan_err!(
@@ -212,7 +214,7 @@ pub fn check_subquery_expr(
}
_ => plan_err!(
"Correlated scalar subquery can only be used in Projection, Filter, Aggregate plan nodes"
- )
+ ),
}?;
}
check_correlations_in_subquery(inner_plan)
diff --git a/datafusion/expr/src/logical_plan/mod.rs b/datafusion/expr/src/logical_plan/mod.rs
index f0212be294..c2b01868c9 100644
--- a/datafusion/expr/src/logical_plan/mod.rs
+++ b/datafusion/expr/src/logical_plan/mod.rs
@@ -21,15 +21,15 @@ pub mod display;
pub mod dml;
mod extension;
pub(crate) mod invariants;
-pub use invariants::{assert_expected_schema, check_subquery_expr, InvariantLevel};
+pub use invariants::{InvariantLevel, assert_expected_schema, check_subquery_expr};
mod plan;
mod statement;
pub mod tree_node;
pub use builder::{
+ LogicalPlanBuilder, LogicalPlanBuilderOptions, LogicalTableSource, UNNAMED_TABLE,
build_join_schema, requalify_sides_if_needed, table_scan, union,
- wrap_projection_for_join_if_necessary, LogicalPlanBuilder, LogicalPlanBuilderOptions,
- LogicalTableSource, UNNAMED_TABLE,
+ wrap_projection_for_join_if_necessary,
};
pub use ddl::{
CreateCatalog, CreateCatalogSchema, CreateExternalTable, CreateFunction,
@@ -38,11 +38,12 @@ pub use ddl::{
};
pub use dml::{DmlStatement, WriteOp};
pub use plan::{
- projection_schema, Aggregate, Analyze, ColumnUnnestList, DescribeTable, Distinct,
- DistinctOn, EmptyRelation, Explain, ExplainOption, Extension, FetchType, Filter,
- Join, JoinConstraint, JoinType, Limit, LogicalPlan, Partitioning, PlanType,
- Projection, RecursiveQuery, Repartition, SkipType, Sort, StringifiedPlan, Subquery,
+ Aggregate, Analyze, ColumnUnnestList, DescribeTable, Distinct, DistinctOn,
+ EmptyRelation, Explain, ExplainOption, Extension, FetchType, Filter, Join,
+ JoinConstraint, JoinType, Limit, LogicalPlan, Partitioning, PlanType, Projection,
+ RecursiveQuery, Repartition, SkipType, Sort, StringifiedPlan, Subquery,
SubqueryAlias, TableScan, ToStringifiedPlan, Union, Unnest, Values, Window,
+ projection_schema,
};
pub use statement::{
Deallocate, Execute, Prepare, ResetVariable, SetVariable, Statement,
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index ad9a46b004..c51be15b67 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -23,19 +23,19 @@ use std::fmt::{self, Debug, Display, Formatter};
use std::hash::{Hash, Hasher};
use std::sync::{Arc, LazyLock};
+use super::DdlStatement;
use super::dml::CopyTo;
use super::invariants::{
- assert_always_invariants_at_current_node, assert_executable_invariants,
- InvariantLevel,
+ InvariantLevel, assert_always_invariants_at_current_node,
+ assert_executable_invariants,
};
-use super::DdlStatement;
use crate::builder::{unique_field_aliases, unnest_with_options};
use crate::expr::{
- intersect_metadata_for_union, Alias, Placeholder, Sort as SortExpr, WindowFunction,
- WindowFunctionParams,
+ Alias, Placeholder, Sort as SortExpr, WindowFunction, WindowFunctionParams,
+ intersect_metadata_for_union,
};
use crate::expr_rewriter::{
- create_col_from_scalar_expr, normalize_cols, normalize_sorts, NamePreserver,
+ NamePreserver, create_col_from_scalar_expr, normalize_cols, normalize_sorts,
};
use crate::logical_plan::display::{GraphvizVisitor, IndentVisitor};
use crate::logical_plan::extension::UserDefinedLogicalNode;
@@ -45,10 +45,9 @@ use crate::utils::{
grouping_set_expr_count, grouping_set_to_exprlist, split_conjunction,
};
use crate::{
- build_join_schema, expr_vec_fmt, requalify_sides_if_needed, BinaryExpr,
- CreateMemoryTable, CreateView, Execute, Expr, ExprSchemable, LogicalPlanBuilder,
- Operator, Prepare, TableProviderFilterPushDown, TableSource,
- WindowFunctionDefinition,
+ BinaryExpr, CreateMemoryTable, CreateView, Execute, Expr, ExprSchemable,
+ LogicalPlanBuilder, Operator, Prepare, TableProviderFilterPushDown, TableSource,
+ WindowFunctionDefinition, build_join_schema, expr_vec_fmt, requalify_sides_if_needed,
};
use arrow::datatypes::{DataType, Field, FieldRef, Schema, SchemaRef};
@@ -59,10 +58,10 @@ use datafusion_common::tree_node::{
Transformed, TreeNode, TreeNodeContainer, TreeNodeRecursion,
};
use datafusion_common::{
- aggregate_functional_dependencies, assert_eq_or_internal_err, assert_or_internal_err,
- internal_err, plan_err, Column, Constraints, DFSchema, DFSchemaRef, DataFusionError,
- Dependency, FunctionalDependence, FunctionalDependencies, NullEquality, ParamValues,
- Result, ScalarValue, Spans, TableReference, UnnestOptions,
+ Column, Constraints, DFSchema, DFSchemaRef, DataFusionError, Dependency,
+ FunctionalDependence, FunctionalDependencies, NullEquality, ParamValues, Result,
+ ScalarValue, Spans, TableReference, UnnestOptions, aggregate_functional_dependencies,
+ assert_eq_or_internal_err, assert_or_internal_err, internal_err, plan_err,
};
use indexmap::IndexSet;
@@ -925,7 +924,9 @@ impl LogicalPlan {
let mut iter = expr.into_iter();
while let Some(left) = iter.next() {
let Some(right) = iter.next() else {
- internal_err!("Expected a pair of expressions to construct the join on expression")?
+ internal_err!(
+ "Expected a pair of expressions to construct the join on expression"
+ )?
};
// SimplifyExpression rule may add alias to the equi_expr.
@@ -1053,7 +1054,10 @@ impl LogicalPlan {
let input = self.only_input(inputs)?;
let sort_expr = expr.split_off(on_expr.len() + select_expr.len());
let select_expr = expr.split_off(on_expr.len());
- assert!(sort_expr.is_empty(), "with_new_exprs for Distinct does not support sort expressions");
+ assert!(
+ sort_expr.is_empty(),
+ "with_new_exprs for Distinct does not support sort expressions"
+ );
Distinct::On(DistinctOn::try_new(
expr,
select_expr,
@@ -1767,16 +1771,19 @@ impl LogicalPlan {
impl Display for Wrapper<'_> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self.0 {
- LogicalPlan::EmptyRelation(EmptyRelation { produce_one_row, schema: _ }) => {
+ LogicalPlan::EmptyRelation(EmptyRelation {
+ produce_one_row,
+ schema: _,
+ }) => {
let rows = if *produce_one_row { 1 } else { 0 };
write!(f, "EmptyRelation: rows={rows}")
- },
+ }
LogicalPlan::RecursiveQuery(RecursiveQuery {
is_distinct, ..
}) => {
write!(f, "RecursiveQuery: is_distinct={is_distinct}")
}
- LogicalPlan::Values(Values { ref values, .. }) => {
+ LogicalPlan::Values(Values { values, .. }) => {
let str_values: Vec<_> = values
.iter()
// limit to only 5 values to avoid horrible display
@@ -1796,11 +1803,11 @@ impl LogicalPlan {
}
LogicalPlan::TableScan(TableScan {
- ref source,
- ref table_name,
- ref projection,
- ref filters,
- ref fetch,
+ source,
+ table_name,
+ projection,
+ filters,
+ fetch,
..
}) => {
let projected_fields = match projection {
@@ -1870,7 +1877,7 @@ impl LogicalPlan {
Ok(())
}
- LogicalPlan::Projection(Projection { ref expr, .. }) => {
+ LogicalPlan::Projection(Projection { expr, .. }) => {
write!(f, "Projection:")?;
for (i, expr_item) in expr.iter().enumerate() {
if i > 0 {
@@ -1896,18 +1903,19 @@ impl LogicalPlan {
.collect::<Vec<String>>()
.join(", ");
- write!(f, "CopyTo: format={} output_url={output_url} options: ({op_str})", file_type.get_ext())
+ write!(
+ f,
+ "CopyTo: format={} output_url={output_url} options: ({op_str})",
+ file_type.get_ext()
+ )
}
LogicalPlan::Ddl(ddl) => {
write!(f, "{}", ddl.display())
}
LogicalPlan::Filter(Filter {
- predicate: ref expr,
- ..
+ predicate: expr, ..
}) => write!(f, "Filter: {expr}"),
- LogicalPlan::Window(Window {
- ref window_expr, ..
- }) => {
+ LogicalPlan::Window(Window { window_expr, .. }) => {
write!(
f,
"WindowAggr: windowExpr=[[{}]]",
@@ -1915,8 +1923,8 @@ impl LogicalPlan {
)
}
LogicalPlan::Aggregate(Aggregate {
- ref group_expr,
- ref aggr_expr,
+ group_expr,
+ aggr_expr,
..
}) => write!(
f,
@@ -1939,7 +1947,7 @@ impl LogicalPlan {
Ok(())
}
LogicalPlan::Join(Join {
- on: ref keys,
+ on: keys,
filter,
join_constraint,
join_type,
@@ -1951,7 +1959,10 @@ impl LogicalPlan {
.as_ref()
.map(|expr| format!(" Filter: {expr}"))
.unwrap_or_else(|| "".to_string());
- let join_type = if filter.is_none() && keys.is_empty() && matches!(join_type, JoinType::Inner) {
+ let join_type = if filter.is_none()
+ && keys.is_empty()
+ && matches!(join_type, JoinType::Inner)
+ {
"Cross".to_string()
} else {
join_type.to_string()
@@ -2008,22 +2019,25 @@ impl LogicalPlan {
// Attempt to display `skip` and `fetch` as literals if possible, otherwise as expressions.
let skip_str = match limit.get_skip_type() {
Ok(SkipType::Literal(n)) => n.to_string(),
- _ => limit.skip.as_ref().map_or_else(|| "None".to_string(), |x| x.to_string()),
+ _ => limit
+ .skip
+ .as_ref()
+ .map_or_else(|| "None".to_string(), |x| x.to_string()),
};
let fetch_str = match limit.get_fetch_type() {
Ok(FetchType::Literal(Some(n))) => n.to_string(),
Ok(FetchType::Literal(None)) => "None".to_string(),
- _ => limit.fetch.as_ref().map_or_else(|| "None".to_string(), |x| x.to_string())
+ _ => limit
+ .fetch
+ .as_ref()
+ .map_or_else(|| "None".to_string(), |x| x.to_string()),
};
- write!(
- f,
- "Limit: skip={skip_str}, fetch={fetch_str}",
- )
+ write!(f, "Limit: skip={skip_str}, fetch={fetch_str}",)
}
LogicalPlan::Subquery(Subquery { .. }) => {
write!(f, "Subquery:")
}
- LogicalPlan::SubqueryAlias(SubqueryAlias { ref alias, .. }) => {
+ LogicalPlan::SubqueryAlias(SubqueryAlias { alias, .. }) => {
write!(f, "SubqueryAlias: {alias}")
}
LogicalPlan::Statement(statement) => {
@@ -2041,7 +2055,11 @@ impl LogicalPlan {
"DistinctOn: on_expr=[[{}]], select_expr=[[{}]], sort_expr=[[{}]]",
expr_vec_fmt!(on_expr),
expr_vec_fmt!(select_expr),
- if let Some(sort_expr) = sort_expr { expr_vec_fmt!(sort_expr) } else { "".to_string() },
+ if let Some(sort_expr) = sort_expr {
+ expr_vec_fmt!(sort_expr)
+ } else {
+ "".to_string()
+ },
),
},
LogicalPlan::Explain { .. } => write!(f, "Explain"),
@@ -2054,22 +2072,31 @@ impl LogicalPlan {
LogicalPlan::Unnest(Unnest {
input: plan,
list_type_columns: list_col_indices,
- struct_type_columns: struct_col_indices, .. }) => {
+ struct_type_columns: struct_col_indices,
+ ..
+ }) => {
let input_columns = plan.schema().columns();
let list_type_columns = list_col_indices
.iter()
- .map(|(i,unnest_info)|
- format!("{}|depth={}", &input_columns[*i].to_string(),
- unnest_info.depth))
+ .map(|(i, unnest_info)| {
+ format!(
+ "{}|depth={}",
+ &input_columns[*i].to_string(),
+ unnest_info.depth
+ )
+ })
.collect::<Vec<String>>();
let struct_type_columns = struct_col_indices
.iter()
.map(|i| &input_columns[*i])
.collect::<Vec<&Column>>();
// get items from input_columns indexed by list_col_indices
- write!(f, "Unnest: lists[{}] structs[{}]",
- expr_vec_fmt!(list_type_columns),
- expr_vec_fmt!(struct_type_columns))
+ write!(
+ f,
+ "Unnest: lists[{}] structs[{}]",
+ expr_vec_fmt!(list_type_columns),
+ expr_vec_fmt!(struct_type_columns)
+ )
}
}
}
@@ -2211,7 +2238,11 @@ impl Projection {
if !expr.iter().any(|e| matches!(e, Expr::Wildcard { .. }))
&& expr.len() != schema.fields().len()
{
- return plan_err!("Projection has mismatch between number of expressions ({}) and number of fields in schema ({})", expr.len(), schema.fields().len());
+ return plan_err!(
+ "Projection has mismatch between number of expressions ({}) and number of fields in schema ({})",
+ expr.len(),
+ schema.fields().len()
+ );
}
Ok(Self {
expr,
@@ -2398,12 +2429,12 @@ impl Filter {
// Note that it is not always possible to resolve the predicate expression during plan
// construction (such as with correlated subqueries) so we make a best effort here and
// ignore errors resolving the expression against the schema.
- if let Ok(predicate_type) = predicate.get_type(input.schema()) {
- if !Filter::is_allowed_filter_type(&predicate_type) {
- return plan_err!(
- "Cannot create filter with non-boolean predicate '{predicate}' returning {predicate_type}"
- );
- }
+ if let Ok(predicate_type) = predicate.get_type(input.schema())
+ && !Filter::is_allowed_filter_type(&predicate_type)
+ {
+ return plan_err!(
+ "Cannot create filter with non-boolean predicate '{predicate}' returning {predicate_type}"
+ );
}
Ok(Self {
@@ -4274,14 +4305,14 @@ mod tests {
use crate::select_expr::SelectExpr;
use crate::test::function_stub::{count, count_udaf};
use crate::{
- binary_expr, col, exists, in_subquery, lit, placeholder, scalar_subquery,
- GroupingSet,
+ GroupingSet, binary_expr, col, exists, in_subquery, lit, placeholder,
+ scalar_subquery,
};
use datafusion_common::metadata::ScalarAndMetadata;
use datafusion_common::tree_node::{
TransformedResult, TreeNodeRewriter, TreeNodeVisitor,
};
- use datafusion_common::{not_impl_err, Constraint, ScalarValue};
+ use datafusion_common::{Constraint, ScalarValue, not_impl_err};
use insta::{assert_debug_snapshot, assert_snapshot};
use std::hash::DefaultHasher;
@@ -4901,14 +4932,18 @@ mod tests {
let output_schema = plan.schema();
- assert!(output_schema
- .field_with_name(None, "foo")
- .unwrap()
- .is_nullable(),);
- assert!(output_schema
- .field_with_name(None, "bar")
- .unwrap()
- .is_nullable());
+ assert!(
+ output_schema
+ .field_with_name(None, "foo")
+ .unwrap()
+ .is_nullable(),
+ );
+ assert!(
+ output_schema
+ .field_with_name(None, "bar")
+ .unwrap()
+ .is_nullable()
+ );
}
#[test]
@@ -5173,7 +5208,11 @@ mod tests {
.transform_down_with_subqueries(|plan| {
match plan {
LogicalPlan::Projection(..) => {
- return Ok(Transformed::new(plan, false, TreeNodeRecursion::Jump))
+ return Ok(Transformed::new(
+ plan,
+ false,
+ TreeNodeRecursion::Jump,
+ ));
}
LogicalPlan::Filter(..) => filter_found = true,
_ => {}
@@ -5193,7 +5232,7 @@ mod tests {
plan,
false,
TreeNodeRecursion::Jump,
- ))
+ ));
}
LogicalPlan::Filter(..) => filter_found = true,
_ => {}
@@ -5223,7 +5262,11 @@ mod tests {
fn f_down(&mut self, node: Self::Node) -> Result<Transformed<Self::Node>> {
match node {
LogicalPlan::Projection(..) => {
- return Ok(Transformed::new(node, false, TreeNodeRecursion::Jump))
+ return Ok(Transformed::new(
+ node,
+ false,
+ TreeNodeRecursion::Jump,
+ ));
}
LogicalPlan::Filter(..) => self.filter_found = true,
_ => {}
diff --git a/datafusion/expr/src/logical_plan/statement.rs b/datafusion/expr/src/logical_plan/statement.rs
index 49a938c9f6..384d99ca08 100644
--- a/datafusion/expr/src/logical_plan/statement.rs
+++ b/datafusion/expr/src/logical_plan/statement.rs
@@ -22,7 +22,7 @@ use itertools::Itertools as _;
use std::fmt::{self, Display};
use std::sync::{Arc, LazyLock};
-use crate::{expr_vec_fmt, Expr, LogicalPlan};
+use crate::{Expr, LogicalPlan, expr_vec_fmt};
/// Various types of Statements.
///
diff --git a/datafusion/expr/src/logical_plan/tree_node.rs b/datafusion/expr/src/logical_plan/tree_node.rs
index 47088370a1..62a27b0a02 100644
--- a/datafusion/expr/src/logical_plan/tree_node.rs
+++ b/datafusion/expr/src/logical_plan/tree_node.rs
@@ -38,11 +38,11 @@
//! * [`LogicalPlan::expressions`]: Return a copy of the plan's expressions
use crate::{
- dml::CopyTo, Aggregate, Analyze, CreateMemoryTable, CreateView, DdlStatement,
- Distinct, DistinctOn, DmlStatement, Execute, Explain, Expr, Extension, Filter, Join,
- Limit, LogicalPlan, Partitioning, Prepare, Projection, RecursiveQuery, Repartition,
- Sort, Statement, Subquery, SubqueryAlias, TableScan, Union, Unnest,
- UserDefinedLogicalNode, Values, Window,
+ Aggregate, Analyze, CreateMemoryTable, CreateView, DdlStatement, Distinct,
+ DistinctOn, DmlStatement, Execute, Explain, Expr, Extension, Filter, Join, Limit,
+ LogicalPlan, Partitioning, Prepare, Projection, RecursiveQuery, Repartition, Sort,
+ Statement, Subquery, SubqueryAlias, TableScan, Union, Unnest, UserDefinedLogicalNode,
+ Values, Window, dml::CopyTo,
};
use datafusion_common::tree_node::TreeNodeRefContainer;
@@ -51,7 +51,7 @@ use datafusion_common::tree_node::{
Transformed, TreeNode, TreeNodeContainer, TreeNodeIterator, TreeNodeRecursion,
TreeNodeRewriter, TreeNodeVisitor,
};
-use datafusion_common::{internal_err, Result};
+use datafusion_common::{Result, internal_err};
impl TreeNode for LogicalPlan {
fn apply_children<'n, F: FnMut(&'n Self) -> Result<TreeNodeRecursion>>(
diff --git a/datafusion/expr/src/partition_evaluator.rs b/datafusion/expr/src/partition_evaluator.rs
index a0f0988b4f..f82bacee1a 100644
--- a/datafusion/expr/src/partition_evaluator.rs
+++ b/datafusion/expr/src/partition_evaluator.rs
@@ -18,7 +18,7 @@
//! Partition evaluation module
use arrow::array::ArrayRef;
-use datafusion_common::{exec_err, not_impl_err, Result, ScalarValue};
+use datafusion_common::{Result, ScalarValue, exec_err, not_impl_err};
use std::fmt::Debug;
use std::ops::Range;
diff --git a/datafusion/expr/src/planner.rs b/datafusion/expr/src/planner.rs
index 25a0f83947..794c394d11 100644
--- a/datafusion/expr/src/planner.rs
+++ b/datafusion/expr/src/planner.rs
@@ -27,8 +27,8 @@ use crate::{
};
use arrow::datatypes::{DataType, Field, SchemaRef};
use datafusion_common::{
- config::ConfigOptions, file_options::file_type::FileType, not_impl_err, DFSchema,
- Result, TableReference,
+ DFSchema, Result, TableReference, config::ConfigOptions,
+ file_options::file_type::FileType, not_impl_err,
};
/// Provides the `SQL` query planner meta-data about tables and
diff --git a/datafusion/expr/src/predicate_bounds.rs b/datafusion/expr/src/predicate_bounds.rs
index 192b2929fd..992d9f88bb 100644
--- a/datafusion/expr/src/predicate_bounds.rs
+++ b/datafusion/expr/src/predicate_bounds.rs
@@ -171,10 +171,10 @@ impl PredicateBoundsEvaluator<'_> {
}
// Check if the expression is the `certainly_null_expr` that was passed in.
- if let Some(certainly_null_expr) = &self.certainly_null_expr {
- if expr.eq(certainly_null_expr) {
- return NullableInterval::TRUE;
- }
+ if let Some(certainly_null_expr) = &self.certainly_null_expr
+ && expr.eq(certainly_null_expr)
+ {
+ return NullableInterval::TRUE;
}
// `expr` is nullable, so our default answer for `is null` is going to be `{ TRUE, FALSE }`.
@@ -235,8 +235,8 @@ mod tests {
use crate::expr::ScalarFunction;
use crate::predicate_bounds::evaluate_bounds;
use crate::{
- binary_expr, col, create_udf, is_false, is_not_false, is_not_null, is_not_true,
- is_not_unknown, is_null, is_true, is_unknown, lit, not, Expr,
+ Expr, binary_expr, col, create_udf, is_false, is_not_false, is_not_null,
+ is_not_true, is_not_unknown, is_null, is_true, is_unknown, lit, not,
};
use arrow::datatypes::{DataType, Field, Schema};
use datafusion_common::{DFSchema, Result, ScalarValue};
diff --git a/datafusion/expr/src/registry.rs b/datafusion/expr/src/registry.rs
index 9554dd68e1..472e065211 100644
--- a/datafusion/expr/src/registry.rs
+++ b/datafusion/expr/src/registry.rs
@@ -20,7 +20,7 @@
use crate::expr_rewriter::FunctionRewrite;
use crate::planner::ExprPlanner;
use crate::{AggregateUDF, ScalarUDF, UserDefinedLogicalNode, WindowUDF};
-use datafusion_common::{not_impl_err, plan_datafusion_err, HashMap, Result};
+use datafusion_common::{HashMap, Result, not_impl_err, plan_datafusion_err};
use std::collections::HashSet;
use std::fmt::Debug;
use std::sync::Arc;
diff --git a/datafusion/expr/src/select_expr.rs b/datafusion/expr/src/select_expr.rs
index bfec4c5844..22b9660572 100644
--- a/datafusion/expr/src/select_expr.rs
+++ b/datafusion/expr/src/select_expr.rs
@@ -20,7 +20,7 @@ use std::fmt;
use arrow::datatypes::FieldRef;
use datafusion_common::{Column, TableReference};
-use crate::{expr::WildcardOptions, Expr};
+use crate::{Expr, expr::WildcardOptions};
/// Represents a SELECT expression in a SQL query.
///
diff --git a/datafusion/expr/src/simplify.rs b/datafusion/expr/src/simplify.rs
index 0d644b8e0c..bbe65904fb 100644
--- a/datafusion/expr/src/simplify.rs
+++ b/datafusion/expr/src/simplify.rs
@@ -18,9 +18,9 @@
//! Structs and traits to provide the information needed for expression simplification.
use arrow::datatypes::DataType;
-use datafusion_common::{internal_datafusion_err, DFSchemaRef, Result};
+use datafusion_common::{DFSchemaRef, Result, internal_datafusion_err};
-use crate::{execution_props::ExecutionProps, Expr, ExprSchemable};
+use crate::{Expr, ExprSchemable, execution_props::ExecutionProps};
/// Provides the information necessary to apply algebraic simplification to an
/// [Expr]. See [SimplifyContext] for one concrete implementation.
@@ -74,10 +74,10 @@ impl<'a> SimplifyContext<'a> {
impl SimplifyInfo for SimplifyContext<'_> {
/// Returns true if this Expr has boolean type
fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
- if let Some(schema) = &self.schema {
- if let Ok(DataType::Boolean) = expr.get_type(schema) {
- return Ok(true);
- }
+ if let Some(schema) = &self.schema
+ && let Ok(DataType::Boolean) = expr.get_type(schema)
+ {
+ return Ok(true);
}
Ok(false)
diff --git a/datafusion/expr/src/test/function_stub.rs b/datafusion/expr/src/test/function_stub.rs
index 8609afeae6..d784169d54 100644
--- a/datafusion/expr/src/test/function_stub.rs
+++ b/datafusion/expr/src/test/function_stub.rs
@@ -22,21 +22,21 @@
use std::any::Any;
use arrow::datatypes::{
- DataType, FieldRef, DECIMAL128_MAX_PRECISION, DECIMAL128_MAX_SCALE,
- DECIMAL256_MAX_PRECISION, DECIMAL256_MAX_SCALE, DECIMAL32_MAX_PRECISION,
- DECIMAL32_MAX_SCALE, DECIMAL64_MAX_PRECISION, DECIMAL64_MAX_SCALE,
+ DECIMAL32_MAX_PRECISION, DECIMAL32_MAX_SCALE, DECIMAL64_MAX_PRECISION,
+ DECIMAL64_MAX_SCALE, DECIMAL128_MAX_PRECISION, DECIMAL128_MAX_SCALE,
+ DECIMAL256_MAX_PRECISION, DECIMAL256_MAX_SCALE, DataType, FieldRef,
};
use datafusion_common::plan_err;
-use datafusion_common::{exec_err, not_impl_err, utils::take_function_args, Result};
+use datafusion_common::{Result, exec_err, not_impl_err, utils::take_function_args};
-use crate::type_coercion::aggregates::NUMERICS;
use crate::Volatility::Immutable;
+use crate::type_coercion::aggregates::NUMERICS;
use crate::{
+ Accumulator, AggregateUDFImpl, Expr, GroupsAccumulator, ReversedUDAF, Signature,
expr::AggregateFunction,
function::{AccumulatorArgs, StateFieldsArgs},
utils::AggregateOrderSensitivity,
- Accumulator, AggregateUDFImpl, Expr, GroupsAccumulator, ReversedUDAF, Signature,
};
macro_rules! create_func {
diff --git a/datafusion/expr/src/tree_node.rs b/datafusion/expr/src/tree_node.rs
index 81846b4f80..742bae5b23 100644
--- a/datafusion/expr/src/tree_node.rs
+++ b/datafusion/expr/src/tree_node.rs
@@ -17,17 +17,17 @@
//! Tree node implementation for Logical Expressions
+use crate::Expr;
use crate::expr::{
AggregateFunction, AggregateFunctionParams, Alias, Between, BinaryExpr, Case, Cast,
GroupingSet, InList, InSubquery, Like, Placeholder, ScalarFunction, TryCast, Unnest,
WindowFunction, WindowFunctionParams,
};
-use crate::Expr;
+use datafusion_common::Result;
use datafusion_common::tree_node::{
Transformed, TreeNode, TreeNodeContainer, TreeNodeRecursion, TreeNodeRefContainer,
};
-use datafusion_common::Result;
/// Implementation of the [`TreeNode`] trait
///
diff --git a/datafusion/expr/src/type_coercion/functions.rs b/datafusion/expr/src/type_coercion/functions.rs
index 0239ed38b6..7be9713f53 100644
--- a/datafusion/expr/src/type_coercion/functions.rs
+++ b/datafusion/expr/src/type_coercion/functions.rs
@@ -24,10 +24,10 @@ use arrow::{
};
use datafusion_common::types::LogicalType;
use datafusion_common::utils::{
- base_type, coerced_fixed_size_list_to_list, ListCoercion,
+ ListCoercion, base_type, coerced_fixed_size_list_to_list,
};
use datafusion_common::{
- exec_err, internal_err, plan_err, types::NativeType, utils::list_ndims, Result,
+ Result, exec_err, internal_err, plan_err, types::NativeType, utils::list_ndims,
};
use datafusion_expr_common::signature::ArrayFunctionArgument;
use datafusion_expr_common::type_coercion::binary::type_union_resolution;
@@ -58,7 +58,10 @@ pub fn data_types_with_scalar_udf(
return Ok(vec![]);
} else if type_signature.used_to_support_zero_arguments() {
// Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
- return plan_err!("'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments", func.name());
+ return plan_err!(
+ "'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments",
+ func.name()
+ );
} else {
return plan_err!("'{}' does not support zero arguments", func.name());
}
@@ -96,7 +99,10 @@ pub fn fields_with_aggregate_udf(
return Ok(vec![]);
} else if type_signature.used_to_support_zero_arguments() {
// Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
- return plan_err!("'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments", func.name());
+ return plan_err!(
+ "'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments",
+ func.name()
+ );
} else {
return plan_err!("'{}' does not support zero arguments", func.name());
}
@@ -148,7 +154,10 @@ pub fn fields_with_window_udf(
return Ok(vec![]);
} else if type_signature.used_to_support_zero_arguments() {
// Special error to help during upgrade: https://github.com/apache/datafusion/issues/13763
- return plan_err!("'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments", func.name());
+ return plan_err!(
+ "'{}' does not support zero arguments. Use TypeSignature::Nullary for zero arguments",
+ func.name()
+ );
} else {
return plan_err!("'{}' does not support zero arguments", func.name());
}
@@ -340,7 +349,7 @@ fn get_valid_types_with_aggregate_udf(
"Function '{}' user-defined coercion failed with {:?}",
func.name(),
e.strip_backtrace()
- )
+ );
}
},
TypeSignature::OneOf(signatures) => signatures
@@ -369,7 +378,7 @@ fn get_valid_types_with_window_udf(
"Function '{}' user-defined coercion failed with {:?}",
func.name(),
e.strip_backtrace()
- )
+ );
}
},
TypeSignature::OneOf(signatures) => signatures
@@ -625,7 +634,9 @@ fn get_valid_types(
if let Some(dt) = comparison_coercion_numeric(&target_type, data_type) {
target_type = dt;
} else {
- return plan_err!("For function '{function_name}' {target_type} and {data_type} is not comparable");
+ return plan_err!(
+ "For function '{function_name}' {target_type} and {data_type} is not comparable"
+ );
}
}
// Convert null to String type.
@@ -642,20 +653,24 @@ fn get_valid_types(
for (current_type, param) in current_types.iter().zip(param_types.iter()) {
let current_native_type: NativeType = current_type.into();
- if param.desired_type().matches_native_type(&current_native_type) {
- let casted_type = param.desired_type().default_casted_type(
- &current_native_type,
- current_type,
- )?;
+ if param
+ .desired_type()
+ .matches_native_type(&current_native_type)
+ {
+ let casted_type = param
+ .desired_type()
+ .default_casted_type(&current_native_type, current_type)?;
new_types.push(casted_type);
} else if param
- .allowed_source_types()
- .iter()
- .any(|t| t.matches_native_type(&current_native_type)) {
+ .allowed_source_types()
+ .iter()
+ .any(|t| t.matches_native_type(&current_native_type))
+ {
// If the condition is met which means `implicit coercion`` is provided so we can safely unwrap
let default_casted_type = param.default_casted_type().unwrap();
- let casted_type = default_casted_type.default_cast_for(current_type)?;
+ let casted_type =
+ default_casted_type.default_cast_for(current_type)?;
new_types.push(casted_type);
} else {
return internal_err!(
@@ -671,7 +686,9 @@ fn get_valid_types(
}
TypeSignature::Uniform(number, valid_types) => {
if *number == 0 {
- return plan_err!("The function '{function_name}' expected at least one argument");
+ return plan_err!(
+ "The function '{function_name}' expected at least one argument"
+ );
}
valid_types
@@ -682,7 +699,7 @@ fn get_valid_types(
TypeSignature::UserDefined => {
return internal_err!(
"Function '{function_name}' user-defined signature should be handled by function-specific coerce_types"
- )
+ );
}
TypeSignature::VariadicAny => {
if current_types.is_empty() {
@@ -693,10 +710,16 @@ fn get_valid_types(
vec![current_types.to_vec()]
}
TypeSignature::Exact(valid_types) => vec![valid_types.clone()],
- TypeSignature::ArraySignature(ref function_signature) => match function_signature {
- ArrayFunctionSignature::Array { arguments, array_coercion, } => {
- array_valid_types(function_name, current_types, arguments, array_coercion.as_ref())?
- }
+ TypeSignature::ArraySignature(function_signature) => match function_signature {
+ ArrayFunctionSignature::Array {
+ arguments,
+ array_coercion,
+ } => array_valid_types(
+ function_name,
+ current_types,
+ arguments,
+ array_coercion.as_ref(),
+ )?,
ArrayFunctionSignature::RecursiveArray => {
if current_types.len() != 1 {
return Ok(vec![vec![]]);
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rs
index df158f8838..a69176e117 100644
--- a/datafusion/expr/src/udaf.rs
+++ b/datafusion/expr/src/udaf.rs
@@ -26,23 +26,23 @@ use std::vec;
use arrow::datatypes::{DataType, Field, FieldRef};
-use datafusion_common::{exec_err, not_impl_err, Result, ScalarValue, Statistics};
+use datafusion_common::{Result, ScalarValue, Statistics, exec_err, not_impl_err};
use datafusion_expr_common::dyn_eq::{DynEq, DynHash};
use datafusion_physical_expr_common::physical_expr::PhysicalExpr;
use crate::expr::{
+ AggregateFunction, AggregateFunctionParams, ExprListDisplay, WindowFunctionParams,
schema_name_from_exprs, schema_name_from_exprs_comma_separated_without_space,
- schema_name_from_sorts, AggregateFunction, AggregateFunctionParams, ExprListDisplay,
- WindowFunctionParams,
+ schema_name_from_sorts,
};
use crate::function::{
AccumulatorArgs, AggregateFunctionSimplification, StateFieldsArgs,
};
use crate::groups_accumulator::GroupsAccumulator;
use crate::udf_eq::UdfEq;
-use crate::utils::format_state_name;
use crate::utils::AggregateOrderSensitivity;
-use crate::{expr_vec_fmt, Accumulator, Expr};
+use crate::utils::format_state_name;
+use crate::{Accumulator, Expr, expr_vec_fmt};
use crate::{Documentation, Signature};
/// Logical representation of a user-defined [aggregate function] (UDAF).
@@ -565,11 +565,12 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync {
/// be derived from `name`. See [`format_state_name`] for a utility function
/// to generate a unique name.
fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<FieldRef>> {
- let fields = vec![args
- .return_field
- .as_ref()
- .clone()
- .with_name(format_state_name(args.name, "value"))];
+ let fields = vec![
+ args.return_field
+ .as_ref()
+ .clone()
+ .with_name(format_state_name(args.name, "value")),
+ ];
Ok(fields
.into_iter()
diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rs
index 9dbda6cd0a..d275e1eb8e 100644
--- a/datafusion/expr/src/udf.rs
+++ b/datafusion/expr/src/udf.rs
@@ -26,7 +26,7 @@ use crate::{ColumnarValue, Documentation, Expr, Signature};
use arrow::datatypes::{DataType, Field, FieldRef};
use datafusion_common::config::ConfigOptions;
use datafusion_common::{
- assert_or_internal_err, not_impl_err, ExprSchema, Result, ScalarValue,
+ ExprSchema, Result, ScalarValue, assert_or_internal_err, not_impl_err,
};
use datafusion_expr_common::dyn_eq::{DynEq, DynHash};
use datafusion_expr_common::interval_arithmetic::Interval;
@@ -91,7 +91,8 @@ impl PartialOrd for ScalarUDF {
"Detected incorrect implementation of PartialEq when comparing functions: '{}' and '{}'. \
The functions compare as equal, but they are not equal based on general properties that \
the PartialOrd implementation observes,",
- self.name(), other.name()
+ self.name(),
+ other.name()
);
Some(cmp)
}
diff --git a/datafusion/expr/src/udwf.rs b/datafusion/expr/src/udwf.rs
index c879e1f762..37055daa1c 100644
--- a/datafusion/expr/src/udwf.rs
+++ b/datafusion/expr/src/udwf.rs
@@ -31,9 +31,9 @@ use arrow::datatypes::{DataType, FieldRef};
use crate::expr::WindowFunction;
use crate::udf_eq::UdfEq;
use crate::{
- function::WindowFunctionSimplification, Expr, PartitionEvaluator, Signature,
+ Expr, PartitionEvaluator, Signature, function::WindowFunctionSimplification,
};
-use datafusion_common::{not_impl_err, Result};
+use datafusion_common::{Result, not_impl_err};
use datafusion_doc::Documentation;
use datafusion_expr_common::dyn_eq::{DynEq, DynHash};
use datafusion_functions_window_common::expr::ExpressionArgs;
diff --git a/datafusion/expr/src/utils.rs b/datafusion/expr/src/utils.rs
index cffeccb6e8..de4ebf5fa9 100644
--- a/datafusion/expr/src/utils.rs
+++ b/datafusion/expr/src/utils.rs
@@ -24,7 +24,7 @@ use std::sync::Arc;
use crate::expr::{Alias, Sort, WildcardOptions, WindowFunctionParams};
use crate::expr_rewriter::strip_outer_reference;
use crate::{
- and, BinaryExpr, Expr, ExprSchemable, Filter, GroupingSet, LogicalPlan, Operator,
+ BinaryExpr, Expr, ExprSchemable, Filter, GroupingSet, LogicalPlan, Operator, and,
};
use datafusion_expr_common::signature::{Signature, TypeSignature};
@@ -34,8 +34,8 @@ use datafusion_common::tree_node::{
};
use datafusion_common::utils::get_at_indices;
use datafusion_common::{
- internal_err, plan_err, Column, DFSchema, DFSchemaRef, HashMap, Result,
- TableReference,
+ Column, DFSchema, DFSchemaRef, HashMap, Result, TableReference, internal_err,
+ plan_err,
};
#[cfg(not(feature = "sql"))]
@@ -114,7 +114,9 @@ pub fn powerset<T>(slice: &[T]) -> Result<Vec<Vec<&T>>> {
fn check_grouping_set_size_limit(size: usize) -> Result<()> {
let max_grouping_set_size = 65535;
if size > max_grouping_set_size {
- return plan_err!("The number of group_expression in grouping_set exceeds the maximum limit {max_grouping_set_size}, found {size}");
+ return plan_err!(
+ "The number of group_expression in grouping_set exceeds the maximum limit {max_grouping_set_size}, found {size}"
+ );
}
Ok(())
@@ -124,7 +126,9 @@ fn check_grouping_set_size_limit(size: usize) -> Result<()> {
fn check_grouping_sets_size_limit(size: usize) -> Result<()> {
let max_grouping_sets_size = 4096;
if size > max_grouping_sets_size {
- return plan_err!("The number of grouping_set in grouping_sets exceeds the maximum limit {max_grouping_sets_size}, found {size}");
+ return plan_err!(
+ "The number of grouping_set in grouping_sets exceeds the maximum limit {max_grouping_sets_size}, found {size}"
+ );
}
Ok(())
@@ -947,9 +951,11 @@ pub fn generate_signature_error_msg(
.join("\n");
format!(
- "No function matches the given name and argument types '{}({})'. You might need to add explicit type casts.\n\tCandidate functions:\n{}",
- func_name, TypeSignature::join_types(input_expr_types, ", "), candidate_signatures
- )
+ "No function matches the given name and argument types '{}({})'. You might need to add explicit type casts.\n\tCandidate functions:\n{}",
+ func_name,
+ TypeSignature::join_types(input_expr_types, ", "),
+ candidate_signatures
+ )
}
/// Splits a conjunctive [`Expr`] such as `A AND B AND C` => `[A, B, C]`
@@ -1280,11 +1286,10 @@ pub fn collect_subquery_cols(
mod tests {
use super::*;
use crate::{
- col, cube,
+ Cast, ExprFunctionExt, WindowFunctionDefinition, col, cube,
expr::WindowFunction,
expr_vec_fmt, grouping_set, lit, rollup,
test::function_stub::{max_udaf, min_udaf, sum_udaf},
- Cast, ExprFunctionExt, WindowFunctionDefinition,
};
use arrow::datatypes::{UnionFields, UnionMode};
use datafusion_expr_common::signature::{TypeSignature, Volatility};
diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rs
index 5fb2916c34..334c1fa2a0 100644
--- a/datafusion/expr/src/window_frame.rs
+++ b/datafusion/expr/src/window_frame.rs
@@ -27,7 +27,7 @@ use crate::{expr::Sort, lit};
use std::fmt::{self, Formatter};
use std::hash::Hash;
-use datafusion_common::{plan_err, Result, ScalarValue};
+use datafusion_common::{Result, ScalarValue, plan_err};
#[cfg(feature = "sql")]
use sqlparser::ast::{self, ValueWithSpan};
@@ -131,12 +131,10 @@ impl TryFrom<ast::WindowFrame> for WindowFrame {
"Invalid window frame: start bound cannot be UNBOUNDED FOLLOWING"
)?
}
- } else if let WindowFrameBound::Preceding(val) = &end_bound {
- if val.is_null() {
- plan_err!(
- "Invalid window frame: end bound cannot be UNBOUNDED PRECEDING"
- )?
- }
+ } else if let WindowFrameBound::Preceding(val) = &end_bound
+ && val.is_null()
+ {
+ plan_err!("Invalid window frame: end bound cannot be UNBOUNDED PRECEDING")?
};
let units = value.units.into();
@@ -375,9 +373,10 @@ fn convert_frame_bound_to_scalar_value(
match units {
// For ROWS and GROUPS we are sure that the ScalarValue must be a non-negative integer ...
ast::WindowFrameUnits::Rows | ast::WindowFrameUnits::Groups => match v {
- ast::Expr::Value(ValueWithSpan{value: ast::Value::Number(value, false), span: _}) => {
- Ok(ScalarValue::try_from_string(value, &DataType::UInt64)?)
- },
+ ast::Expr::Value(ValueWithSpan {
+ value: ast::Value::Number(value, false),
+ span: _,
+ }) => Ok(ScalarValue::try_from_string(value, &DataType::UInt64)?),
ast::Expr::Interval(ast::Interval {
value,
leading_field: None,
@@ -386,11 +385,12 @@ fn convert_frame_bound_to_scalar_value(
fractional_seconds_precision: None,
}) => {
let value = match *value {
- ast::Expr::Value(ValueWithSpan{value: ast::Value::SingleQuotedString(item), span: _}) => item,
+ ast::Expr::Value(ValueWithSpan {
+ value: ast::Value::SingleQuotedString(item),
+ span: _,
+ }) => item,
e => {
- return exec_err!(
- "INTERVAL expression cannot be {e:?}"
- );
+ return exec_err!("INTERVAL expression cannot be {e:?}");
}
};
Ok(ScalarValue::try_from_string(value, &DataType::UInt64)?)
@@ -402,18 +402,22 @@ fn convert_frame_bound_to_scalar_value(
// ... instead for RANGE it could be anything depending on the type of the ORDER BY clause,
// so we use a ScalarValue::Utf8.
ast::WindowFrameUnits::Range => Ok(ScalarValue::Utf8(Some(match v {
- ast::Expr::Value(ValueWithSpan{value: ast::Value::Number(value, false), span: _}) => value,
+ ast::Expr::Value(ValueWithSpan {
+ value: ast::Value::Number(value, false),
+ span: _,
+ }) => value,
ast::Expr::Interval(ast::Interval {
value,
leading_field,
..
}) => {
let result = match *value {
- ast::Expr::Value(ValueWithSpan{value: ast::Value::SingleQuotedString(item), span: _}) => item,
+ ast::Expr::Value(ValueWithSpan {
+ value: ast::Value::SingleQuotedString(item),
+ span: _,
+ }) => item,
e => {
- return exec_err!(
- "INTERVAL expression cannot be {e:?}"
- );
+ return exec_err!("INTERVAL expression cannot be {e:?}");
}
};
if let Some(leading_field) = leading_field {
@@ -604,8 +608,16 @@ mod tests {
last_field: None,
leading_precision: None,
})));
- test_bound_err!(Rows, number.clone(), "Error during planning: Invalid window frame: frame offsets for ROWS / GROUPS must be non negative integers");
- test_bound_err!(Groups, number.clone(), "Error during planning: Invalid window frame: frame offsets for ROWS / GROUPS must be non negative integers");
+ test_bound_err!(
+ Rows,
+ number.clone(),
+ "Error during planning: Invalid window frame: frame offsets for ROWS / GROUPS must be non negative integers"
+ );
+ test_bound_err!(
+ Groups,
+ number.clone(),
+ "Error during planning: Invalid window frame: frame offsets for ROWS / GROUPS must be non negative integers"
+ );
test_bound!(
Range,
number.clone(),
diff --git a/datafusion/expr/src/window_state.rs b/datafusion/expr/src/window_state.rs
index cdfb18ee1d..d7da7a778b 100644
--- a/datafusion/expr/src/window_state.rs
+++ b/datafusion/expr/src/window_state.rs
@@ -23,14 +23,13 @@ use crate::{WindowFrame, WindowFrameBound, WindowFrameUnits};
use arrow::{
array::ArrayRef,
- compute::{concat, concat_batches, SortOptions},
+ compute::{SortOptions, concat, concat_batches},
datatypes::{DataType, SchemaRef},
record_batch::RecordBatch,
};
use datafusion_common::{
- internal_datafusion_err, internal_err,
+ Result, ScalarValue, internal_datafusion_err, internal_err,
utils::{compare_rows, get_row_at_idx, search_in_slice},
- Result, ScalarValue,
};
/// Holds the state of evaluating a window function
@@ -170,7 +169,7 @@ impl WindowFrameContext {
// comparison of rows.
WindowFrameContext::Range {
window_frame,
- ref mut state,
+ state,
} => state.calculate_range(
window_frame,
last_range,
@@ -183,7 +182,7 @@ impl WindowFrameContext {
// or position of NULLs do not impact inequality.
WindowFrameContext::Groups {
window_frame,
- ref mut state,
+ state,
} => state.calculate_range(window_frame, range_columns, length, idx),
}
}
@@ -205,14 +204,14 @@ impl WindowFrameContext {
WindowFrameBound::Following(ScalarValue::UInt64(None)) => {
return internal_err!(
"Frame start cannot be UNBOUNDED FOLLOWING '{window_frame:?}'"
- )
+ );
}
WindowFrameBound::Following(ScalarValue::UInt64(Some(n))) => {
std::cmp::min(idx + n as usize, length)
}
// ERRONEOUS FRAMES
WindowFrameBound::Preceding(_) | WindowFrameBound::Following(_) => {
- return internal_err!("Rows should be UInt64")
+ return internal_err!("Rows should be UInt64");
}
};
let end = match window_frame.end_bound {
@@ -220,7 +219,7 @@ impl WindowFrameContext {
WindowFrameBound::Preceding(ScalarValue::UInt64(None)) => {
return internal_err!(
"Frame end cannot be UNBOUNDED PRECEDING '{window_frame:?}'"
- )
+ );
}
WindowFrameBound::Preceding(ScalarValue::UInt64(Some(n))) => {
if idx >= n as usize {
@@ -237,7 +236,7 @@ impl WindowFrameContext {
}
// ERRONEOUS FRAMES
WindowFrameBound::Preceding(_) | WindowFrameBound::Following(_) => {
- return internal_err!("Rows should be UInt64")
+ return internal_err!("Rows should be UInt64");
}
};
Ok(Range { start, end })