This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new b932cdb3b7 Minor: added to docs in expr folder (#12882)
b932cdb3b7 is described below

commit b932cdb3b7dcff97fe05c6ea3976b7d924b10200
Author: Jonathan Chen <[email protected]>
AuthorDate: Mon Oct 14 07:41:08 2024 -0400

    Minor: added to docs in expr folder (#12882)
    
    * Documentation fixes + add
    
    * fmt fix
    
    * quick fix
---
 datafusion/expr/src/built_in_window_function.rs | 30 ++++++++++-----------
 datafusion/expr/src/conditional_expressions.rs  |  4 +--
 datafusion/expr/src/expr.rs                     | 18 ++++++-------
 datafusion/expr/src/expr_schema.rs              | 35 +++++++++++++++----------
 datafusion/expr/src/function.rs                 |  4 +--
 datafusion/expr/src/simplify.rs                 |  8 +++---
 datafusion/expr/src/tree_node.rs                | 19 +++++++++++++-
 datafusion/expr/src/udaf.rs                     |  8 +++---
 datafusion/expr/src/udf_docs.rs                 | 18 ++++++-------
 datafusion/expr/src/utils.rs                    | 20 +++++++-------
 datafusion/expr/src/window_state.rs             |  2 +-
 11 files changed, 95 insertions(+), 71 deletions(-)

diff --git a/datafusion/expr/src/built_in_window_function.rs 
b/datafusion/expr/src/built_in_window_function.rs
index 117ff08253..6a30080fb3 100644
--- a/datafusion/expr/src/built_in_window_function.rs
+++ b/datafusion/expr/src/built_in_window_function.rs
@@ -37,28 +37,28 @@ impl fmt::Display for BuiltInWindowFunction {
 
 /// A [window function] built in to DataFusion
 ///
-/// [window function]: https://en.wikipedia.org/wiki/Window_function_(SQL)
+/// [Window Function]: https://en.wikipedia.org/wiki/Window_function_(SQL)
 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash, EnumIter)]
 pub enum BuiltInWindowFunction {
-    /// relative rank of the current row: (number of rows preceding or peer 
with current row) / (total rows)
+    /// Relative rank of the current row: (number of rows preceding or peer 
with current row) / (total rows)
     CumeDist,
-    /// integer ranging from 1 to the argument value, dividing the partition 
as equally as possible
+    /// Integer ranging from 1 to the argument value, dividing the partition 
as equally as possible
     Ntile,
-    /// returns value evaluated at the row that is offset rows before the 
current row within the partition;
-    /// if there is no such row, instead return default (which must be of the 
same type as value).
+    /// Returns value evaluated at the row that is offset rows before the 
current row within the partition;
+    /// If there is no such row, instead return default (which must be of the 
same type as value).
     /// Both offset and default are evaluated with respect to the current row.
     /// If omitted, offset defaults to 1 and default to null
     Lag,
-    /// returns value evaluated at the row that is offset rows after the 
current row within the partition;
-    /// if there is no such row, instead return default (which must be of the 
same type as value).
+    /// Returns value evaluated at the row that is offset rows after the 
current row within the partition;
+    /// If there is no such row, instead return default (which must be of the 
same type as value).
     /// Both offset and default are evaluated with respect to the current row.
     /// If omitted, offset defaults to 1 and default to null
     Lead,
-    /// returns value evaluated at the row that is the first row of the window 
frame
+    /// Returns value evaluated at the row that is the first row of the window 
frame
     FirstValue,
-    /// returns value evaluated at the row that is the last row of the window 
frame
+    /// Returns value evaluated at the row that is the last row of the window 
frame
     LastValue,
-    /// returns value evaluated at the row that is the nth row of the window 
frame (counting from 1); null if no such row
+    /// Returns value evaluated at the row that is the nth row of the window 
frame (counting from 1); returns null if no such row
     NthValue,
 }
 
@@ -99,10 +99,10 @@ impl BuiltInWindowFunction {
         // Note that this function *must* return the same type that the 
respective physical expression returns
         // or the execution panics.
 
-        // verify that this is a valid set of data types for this function
+        // Verify that this is a valid set of data types for this function
         data_types(input_expr_types, &self.signature())
-            // original errors are all related to wrong function signature
-            // aggregate them for better error message
+            // Original errors are all related to wrong function signature
+            // Aggregate them for better error message
             .map_err(|_| {
                 plan_datafusion_err!(
                     "{}",
@@ -125,9 +125,9 @@ impl BuiltInWindowFunction {
         }
     }
 
-    /// the signatures supported by the built-in window function `fun`.
+    /// The signatures supported by the built-in window function `fun`.
     pub fn signature(&self) -> Signature {
-        // note: the physical expression must accept the type returned by this 
function or the execution panics.
+        // Note: The physical expression must accept the type returned by this 
function or the execution panics.
         match self {
             BuiltInWindowFunction::CumeDist => Signature::any(0, 
Volatility::Immutable),
             BuiltInWindowFunction::Lag | BuiltInWindowFunction::Lead => {
diff --git a/datafusion/expr/src/conditional_expressions.rs 
b/datafusion/expr/src/conditional_expressions.rs
index 7a2bf4b6c4..23cc88f1c0 100644
--- a/datafusion/expr/src/conditional_expressions.rs
+++ b/datafusion/expr/src/conditional_expressions.rs
@@ -64,7 +64,7 @@ impl CaseBuilder {
     }
 
     fn build(&self) -> Result<Expr> {
-        // collect all "then" expressions
+        // Collect all "then" expressions
         let mut then_expr = self.then_expr.clone();
         if let Some(e) = &self.else_expr {
             then_expr.push(e.as_ref().to_owned());
@@ -79,7 +79,7 @@ impl CaseBuilder {
             .collect::<Result<Vec<_>>>()?;
 
         if then_types.contains(&DataType::Null) {
-            // cannot verify types until execution type
+            // Cannot verify types until execution type
         } else {
             let unique_types: HashSet<&DataType> = then_types.iter().collect();
             if unique_types.len() != 1 {
diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs
index 723433f573..3e692189e4 100644
--- a/datafusion/expr/src/expr.rs
+++ b/datafusion/expr/src/expr.rs
@@ -722,7 +722,7 @@ impl WindowFunctionDefinition {
         }
     }
 
-    /// the signatures supported by the function `fun`.
+    /// The signatures supported by the function `fun`.
     pub fn signature(&self) -> Signature {
         match self {
             WindowFunctionDefinition::BuiltInWindowFunction(fun) => 
fun.signature(),
@@ -846,7 +846,7 @@ pub fn find_df_window_func(name: &str) -> 
Option<WindowFunctionDefinition> {
 /// EXISTS expression
 #[derive(Clone, PartialEq, Eq, PartialOrd, Hash, Debug)]
 pub struct Exists {
-    /// subquery that will produce a single column of data
+    /// Subquery that will produce a single column of data
     pub subquery: Subquery,
     /// Whether the expression is negated
     pub negated: bool,
@@ -1329,7 +1329,7 @@ impl Expr {
                     expr,
                     Expr::Exists { .. } | Expr::ScalarSubquery(_) | 
Expr::InSubquery(_)
                 ) {
-                    // subqueries could contain aliases so don't recurse into 
those
+                    // Subqueries could contain aliases so don't recurse into 
those
                     TreeNodeRecursion::Jump
                 } else {
                     TreeNodeRecursion::Continue
@@ -1346,7 +1346,7 @@ impl Expr {
                 }
             },
         )
-        // unreachable code: internal closure doesn't return err
+        // Unreachable code: internal closure doesn't return err
         .unwrap()
     }
 
@@ -1416,7 +1416,7 @@ impl Expr {
         ))
     }
 
-    /// return `self NOT BETWEEN low AND high`
+    /// Return `self NOT BETWEEN low AND high`
     pub fn not_between(self, low: Expr, high: Expr) -> Expr {
         Expr::Between(Between::new(
             Box::new(self),
@@ -1817,7 +1817,7 @@ impl Expr {
     }
 }
 
-// modifies expr if it is a placeholder with datatype of right
+// Modifies expr if it is a placeholder with datatype of right
 fn rewrite_placeholder(expr: &mut Expr, other: &Expr, schema: &DFSchema) -> 
Result<()> {
     if let Expr::Placeholder(Placeholder { id: _, data_type }) = expr {
         if data_type.is_none() {
@@ -1890,7 +1890,7 @@ impl<'a> Display for SchemaDisplay<'a> {
 
                 Ok(())
             }
-            // expr is not shown since it is aliased
+            // Expr is not shown since it is aliased
             Expr::Alias(Alias { name, .. }) => write!(f, "{name}"),
             Expr::Between(Between {
                 expr,
@@ -1945,7 +1945,7 @@ impl<'a> Display for SchemaDisplay<'a> {
 
                 write!(f, "END")
             }
-            // cast expr is not shown to be consistant with Postgres and Spark 
<https://github.com/apache/datafusion/pull/3222>
+            // Cast expr is not shown to be consistant with Postgres and Spark 
<https://github.com/apache/datafusion/pull/3222>
             Expr::Cast(Cast { expr, .. }) | Expr::TryCast(TryCast { expr, .. 
}) => {
                 write!(f, "{}", SchemaDisplay(expr))
             }
@@ -2415,7 +2415,7 @@ mod test {
         let expected_canonical = "CAST(Float32(1.23) AS Utf8)";
         assert_eq!(expected_canonical, expr.canonical_name());
         assert_eq!(expected_canonical, format!("{expr}"));
-        // note that CAST intentionally has a name that is different from its 
`Display`
+        // Note that CAST intentionally has a name that is different from its 
`Display`
         // representation. CAST does not change the name of expressions.
         assert_eq!("Float32(1.23)", expr.schema_name().to_string());
         Ok(())
diff --git a/datafusion/expr/src/expr_schema.rs 
b/datafusion/expr/src/expr_schema.rs
index ad617c53d6..07a36672f2 100644
--- a/datafusion/expr/src/expr_schema.rs
+++ b/datafusion/expr/src/expr_schema.rs
@@ -35,27 +35,27 @@ use 
datafusion_functions_window_common::field::WindowUDFFieldArgs;
 use std::collections::HashMap;
 use std::sync::Arc;
 
-/// trait to allow expr to typable with respect to a schema
+/// Trait to allow expr to typable with respect to a schema
 pub trait ExprSchemable {
-    /// given a schema, return the type of the expr
+    /// Given a schema, return the type of the expr
     fn get_type(&self, schema: &dyn ExprSchema) -> Result<DataType>;
 
-    /// given a schema, return the nullability of the expr
+    /// Given a schema, return the nullability of the expr
     fn nullable(&self, input_schema: &dyn ExprSchema) -> Result<bool>;
 
-    /// given a schema, return the expr's optional metadata
+    /// Given a schema, return the expr's optional metadata
     fn metadata(&self, schema: &dyn ExprSchema) -> Result<HashMap<String, 
String>>;
 
-    /// convert to a field with respect to a schema
+    /// Convert to a field with respect to a schema
     fn to_field(
         &self,
         input_schema: &dyn ExprSchema,
     ) -> Result<(Option<TableReference>, Arc<Field>)>;
 
-    /// cast to a type with respect to a schema
+    /// Cast to a type with respect to a schema
     fn cast_to(self, cast_to_type: &DataType, schema: &dyn ExprSchema) -> 
Result<Expr>;
 
-    /// given a schema, return the type and nullability of the expr
+    /// Given a schema, return the type and nullability of the expr
     fn data_type_and_nullable(&self, schema: &dyn ExprSchema)
         -> Result<(DataType, bool)>;
 }
@@ -150,7 +150,7 @@ impl ExprSchemable for Expr {
                     .map(|e| e.get_type(schema))
                     .collect::<Result<Vec<_>>>()?;
 
-                // verify that function is invoked with correct number and 
type of arguments as defined in `TypeSignature`
+                // Verify that function is invoked with correct number and 
type of arguments as defined in `TypeSignature`
                 let new_data_types = 
data_types_with_scalar_udf(&arg_data_types, func)
                     .map_err(|err| {
                         plan_datafusion_err!(
@@ -164,7 +164,7 @@ impl ExprSchemable for Expr {
                         )
                     })?;
 
-                // perform additional function arguments validation (due to 
limited
+                // Perform additional function arguments validation (due to 
limited
                 // expressiveness of `TypeSignature`), then infer return type
                 Ok(func.return_type_from_exprs(args, schema, &new_data_types)?)
             }
@@ -223,7 +223,7 @@ impl ExprSchemable for Expr {
             }
             Expr::Wildcard { .. } => Ok(DataType::Null),
             Expr::GroupingSet(_) => {
-                // grouping sets do not really have a type and do not appear 
in projections
+                // Grouping sets do not really have a type and do not appear 
in projections
                 Ok(DataType::Null)
             }
         }
@@ -279,7 +279,7 @@ impl ExprSchemable for Expr {
             Expr::OuterReferenceColumn(_, _) => Ok(true),
             Expr::Literal(value) => Ok(value.is_null()),
             Expr::Case(case) => {
-                // this expression is nullable if any of the input expressions 
are nullable
+                // This expression is nullable if any of the input expressions 
are nullable
                 let then_nullable = case
                     .when_then_expr
                     .iter()
@@ -336,7 +336,7 @@ impl ExprSchemable for Expr {
             }
             Expr::Wildcard { .. } => Ok(false),
             Expr::GroupingSet(_) => {
-                // grouping sets do not really have the concept of nullable 
and do not appear
+                // Grouping sets do not really have the concept of nullable 
and do not appear
                 // in projections
                 Ok(true)
             }
@@ -439,7 +439,7 @@ impl ExprSchemable for Expr {
             return Ok(self);
         }
 
-        // TODO(kszucs): most of the operations do not validate the type 
correctness
+        // TODO(kszucs): Most of the operations do not validate the type 
correctness
         // like all of the binary expressions below. Perhaps Expr should track 
the
         // type of the expression?
 
@@ -526,7 +526,14 @@ impl Expr {
     }
 }
 
-/// cast subquery in InSubquery/ScalarSubquery to a given type.
+/// Cast subquery in InSubquery/ScalarSubquery to a given type.
+///
+/// 1. **Projection plan**: If the subquery is a projection (i.e. a SELECT 
statement with specific
+///    columns), it casts the first expression in the projection to the target 
type and creates a
+///    new projection with the casted expression.
+/// 2. **Non-projection plan**: If the subquery isn't a projection, it adds a 
projection to the plan
+///    with the casted first column.
+///
 pub fn cast_subquery(subquery: Subquery, cast_to_type: &DataType) -> 
Result<Subquery> {
     if subquery.subquery.schema().field(0).data_type() == cast_to_type {
         return Ok(subquery);
diff --git a/datafusion/expr/src/function.rs b/datafusion/expr/src/function.rs
index 9814d16ddf..fca45dfe14 100644
--- a/datafusion/expr/src/function.rs
+++ b/datafusion/expr/src/function.rs
@@ -67,7 +67,7 @@ pub type StateTypeFunction =
 /// * 'aggregate_function': [crate::expr::AggregateFunction] for which 
simplified has been invoked
 /// * 'info': [crate::simplify::SimplifyInfo]
 ///
-/// closure returns simplified [Expr] or an error.
+///Cclosure returns simplified [Expr] or an error.
 pub type AggregateFunctionSimplification = Box<
     dyn Fn(
         crate::expr::AggregateFunction,
@@ -80,7 +80,7 @@ pub type AggregateFunctionSimplification = Box<
 /// * 'window_function': [crate::expr::WindowFunction] for which simplified 
has been invoked
 /// * 'info': [crate::simplify::SimplifyInfo]
 ///
-/// closure returns simplified [Expr] or an error.
+/// Closure returns simplified [Expr] or an error.
 pub type WindowFunctionSimplification = Box<
     dyn Fn(
         crate::expr::WindowFunction,
diff --git a/datafusion/expr/src/simplify.rs b/datafusion/expr/src/simplify.rs
index a55cb49b1f..e636fabf10 100644
--- a/datafusion/expr/src/simplify.rs
+++ b/datafusion/expr/src/simplify.rs
@@ -29,10 +29,10 @@ use crate::{execution_props::ExecutionProps, Expr, 
ExprSchemable};
 /// information in without having to create `DFSchema` objects. If you
 /// have a [`DFSchemaRef`] you can use [`SimplifyContext`]
 pub trait SimplifyInfo {
-    /// returns true if this Expr has boolean type
+    /// Returns true if this Expr has boolean type
     fn is_boolean_type(&self, expr: &Expr) -> Result<bool>;
 
-    /// returns true of this expr is nullable (could possibly be NULL)
+    /// Returns true of this expr is nullable (could possibly be NULL)
     fn nullable(&self, expr: &Expr) -> Result<bool>;
 
     /// Returns details needed for partial expression evaluation
@@ -72,7 +72,7 @@ impl<'a> SimplifyContext<'a> {
 }
 
 impl<'a> SimplifyInfo for SimplifyContext<'a> {
-    /// returns true if this Expr has boolean type
+    /// 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) {
@@ -113,7 +113,7 @@ impl<'a> SimplifyInfo for SimplifyContext<'a> {
 pub enum ExprSimplifyResult {
     /// The function call was simplified to an entirely new Expr
     Simplified(Expr),
-    /// the function call could not be simplified, and the arguments
+    /// The function call could not be simplified, and the arguments
     /// are return unmodified.
     Original(Vec<Expr>),
 }
diff --git a/datafusion/expr/src/tree_node.rs b/datafusion/expr/src/tree_node.rs
index c7c498dd3f..90afe5722a 100644
--- a/datafusion/expr/src/tree_node.rs
+++ b/datafusion/expr/src/tree_node.rs
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-//! Tree node implementation for logical expr
+//! Tree node implementation for Logical Expressions
 
 use crate::expr::{
     AggregateFunction, Alias, Between, BinaryExpr, Case, Cast, GroupingSet, 
InList,
@@ -28,7 +28,16 @@ use datafusion_common::tree_node::{
 };
 use datafusion_common::{map_until_stop_and_collect, Result};
 
+/// Implementation of the [`TreeNode`] trait
+///
+/// This allows logical expressions (`Expr`) to be traversed and transformed
+/// Facilitates tasks such as optimization and rewriting during query
+/// planning.
 impl TreeNode for Expr {
+    /// Applies a function `f` to each child expression of `self`.
+    ///
+    /// The function `f` determines whether to continue traversing the tree or 
to stop.
+    /// This method collects all child expressions and applies `f` to each.
     fn apply_children<'n, F: FnMut(&'n Self) -> Result<TreeNodeRecursion>>(
         &'n self,
         f: F,
@@ -122,6 +131,10 @@ impl TreeNode for Expr {
         children.into_iter().apply_until_stop(f)
     }
 
+    /// Maps each child of `self` using the provided closure `f`.
+    ///
+    /// The closure `f` takes ownership of an expression and returns a 
`Transformed` result,
+    /// indicating whether the expression was transformed or left unchanged.
     fn map_children<F: FnMut(Self) -> Result<Transformed<Self>>>(
         self,
         mut f: F,
@@ -346,6 +359,7 @@ impl TreeNode for Expr {
     }
 }
 
+/// Transforms a boxed expression by applying the provided closure `f`.
 fn transform_box<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
     be: Box<Expr>,
     f: &mut F,
@@ -353,6 +367,7 @@ fn transform_box<F: FnMut(Expr) -> 
Result<Transformed<Expr>>>(
     Ok(f(*be)?.update_data(Box::new))
 }
 
+/// Transforms an optional boxed expression by applying the provided closure 
`f`.
 fn transform_option_box<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
     obe: Option<Box<Expr>>,
     f: &mut F,
@@ -380,6 +395,7 @@ fn transform_vec<F: FnMut(Expr) -> 
Result<Transformed<Expr>>>(
     ve.into_iter().map_until_stop_and_collect(f)
 }
 
+/// Transforms an optional vector of sort expressions by applying the provided 
closure `f`.
 pub fn transform_sort_option_vec<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
     sorts_option: Option<Vec<Sort>>,
     f: &mut F,
@@ -389,6 +405,7 @@ pub fn transform_sort_option_vec<F: FnMut(Expr) -> 
Result<Transformed<Expr>>>(
     })
 }
 
+/// Transforms an vector of sort expressions by applying the provided closure 
`f`.
 pub fn transform_sort_vec<F: FnMut(Expr) -> Result<Transformed<Expr>>>(
     sorts: Vec<Sort>,
     mut f: &mut F,
diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rs
index 6e48054bcf..dbbf88447b 100644
--- a/datafusion/expr/src/udaf.rs
+++ b/datafusion/expr/src/udaf.rs
@@ -140,7 +140,7 @@ impl AggregateUDF {
         ))
     }
 
-    /// creates an [`Expr`] that calls the aggregate function.
+    /// Creates an [`Expr`] that calls the aggregate function.
     ///
     /// This utility allows using the UDAF without requiring access to
     /// the registry, such as with the DataFrame API.
@@ -603,8 +603,8 @@ pub trait AggregateUDFImpl: Debug + Send + Sync {
     }
 
     /// If this function is max, return true
-    /// if the function is min, return false
-    /// otherwise return None (the default)
+    /// If the function is min, return false
+    /// Otherwise return None (the default)
     ///
     ///
     /// Note: this is used to use special aggregate implementations in certain 
conditions
@@ -647,7 +647,7 @@ impl PartialEq for dyn AggregateUDFImpl {
     }
 }
 
-// manual implementation of `PartialOrd`
+// Manual implementation of `PartialOrd`
 // There might be some wackiness with it, but this is based on the impl of eq 
for AggregateUDFImpl
 // 
https://users.rust-lang.org/t/how-to-compare-two-trait-objects-for-equality/88063/5
 impl PartialOrd for dyn AggregateUDFImpl {
diff --git a/datafusion/expr/src/udf_docs.rs b/datafusion/expr/src/udf_docs.rs
index e0ce752603..8e25556660 100644
--- a/datafusion/expr/src/udf_docs.rs
+++ b/datafusion/expr/src/udf_docs.rs
@@ -33,21 +33,21 @@ use datafusion_common::Result;
 /// thus all text should be in English.
 #[derive(Debug, Clone)]
 pub struct Documentation {
-    /// the section in the documentation where the UDF will be documented
+    /// The section in the documentation where the UDF will be documented
     pub doc_section: DocSection,
-    /// the description for the UDF
+    /// The description for the UDF
     pub description: String,
-    /// a brief example of the syntax. For example "ascii(str)"
+    /// A brief example of the syntax. For example "ascii(str)"
     pub syntax_example: String,
-    /// a sql example for the UDF, usually in the form of a sql prompt
+    /// A sql example for the UDF, usually in the form of a sql prompt
     /// query and output. It is strongly recommended to provide an
     /// example for anything but the most basic UDF's
     pub sql_example: Option<String>,
-    /// arguments for the UDF which will be displayed in array order.
+    /// Arguments for the UDF which will be displayed in array order.
     /// Left member of a pair is the argument name, right is a
     /// description for the argument
     pub arguments: Option<Vec<(String, String)>>,
-    /// related functions if any. Values should match the related
+    /// Related functions if any. Values should match the related
     /// udf's name exactly. Related udf's must be of the same
     /// UDF type (scalar, aggregate or window) for proper linking to
     /// occur
@@ -63,12 +63,12 @@ impl Documentation {
 
 #[derive(Debug, Clone, PartialEq)]
 pub struct DocSection {
-    /// true to include this doc section in the public
+    /// True to include this doc section in the public
     /// documentation, false otherwise
     pub include: bool,
-    /// a display label for the doc section. For example: "Math Expressions"
+    /// A display label for the doc section. For example: "Math Expressions"
     pub label: &'static str,
-    /// an optional description for the doc section
+    /// An optional description for the doc section
     pub description: Option<&'static str>,
 }
 
diff --git a/datafusion/expr/src/utils.rs b/datafusion/expr/src/utils.rs
index 06cf1ec693..9ee13f1e06 100644
--- a/datafusion/expr/src/utils.rs
+++ b/datafusion/expr/src/utils.rs
@@ -205,7 +205,7 @@ pub fn enumerate_grouping_sets(group_expr: Vec<Expr>) -> 
Result<Vec<Expr>> {
     if !has_grouping_set || group_expr.len() == 1 {
         return Ok(group_expr);
     }
-    // only process mix grouping sets
+    // Only process mix grouping sets
     let partial_sets = group_expr
         .iter()
         .map(|expr| {
@@ -234,7 +234,7 @@ pub fn enumerate_grouping_sets(group_expr: Vec<Expr>) -> 
Result<Vec<Expr>> {
         })
         .collect::<Result<Vec<_>>>()?;
 
-    // cross join
+    // Cross Join
     let grouping_sets = partial_sets
         .into_iter()
         .map(Ok)
@@ -342,7 +342,7 @@ fn get_excluded_columns(
     // Excluded columns should be unique
     let n_elem = idents.len();
     let unique_idents = idents.into_iter().collect::<HashSet<_>>();
-    // if HashSet size, and vector length are different, this means that some 
of the excluded columns
+    // If HashSet size, and vector length are different, this means that some 
of the excluded columns
     // are not unique. In this case return error.
     if n_elem != unique_idents.len() {
         return plan_err!("EXCLUDE or EXCEPT contains duplicate column names");
@@ -466,7 +466,7 @@ pub fn expand_qualified_wildcard(
 }
 
 /// (expr, "is the SortExpr for window (either comes from PARTITION BY or 
ORDER BY columns)")
-/// if bool is true SortExpr comes from `PARTITION BY` column, if false comes 
from `ORDER BY` column
+/// If bool is true SortExpr comes from `PARTITION BY` column, if false comes 
from `ORDER BY` column
 type WindowSortKey = Vec<(Sort, bool)>;
 
 /// Generate a sort key for a given window expr's partition_by and order_by 
expr
@@ -573,7 +573,7 @@ pub fn compare_sort_expr(
     Ordering::Equal
 }
 
-/// group a slice of window expression expr by their order by expressions
+/// Group a slice of window expression expr by their order by expressions
 pub fn group_window_expr_by_sort_keys(
     window_expr: Vec<Expr>,
 ) -> Result<Vec<(WindowSortKey, Vec<Expr>)>> {
@@ -656,7 +656,7 @@ where
             if !(exprs.contains(expr)) {
                 exprs.push(expr.clone())
             }
-            // stop recursing down this expr once we find a match
+            // Stop recursing down this expr once we find a match
             return Ok(TreeNodeRecursion::Jump);
         }
 
@@ -675,7 +675,7 @@ where
     let mut err = Ok(());
     expr.apply(|expr| {
         if let Err(e) = f(expr) {
-            // save the error for later (it may not be a DataFusionError
+            // Save the error for later (it may not be a DataFusionError)
             err = Err(e);
             Ok(TreeNodeRecursion::Stop)
         } else {
@@ -694,7 +694,7 @@ pub fn exprlist_to_fields<'a>(
     exprs: impl IntoIterator<Item = &'a Expr>,
     plan: &LogicalPlan,
 ) -> Result<Vec<(Option<TableReference>, Arc<Field>)>> {
-    // look for exact match in plan's output schema
+    // Look for exact match in plan's output schema
     let wildcard_schema = find_base_plan(plan).schema();
     let input_schema = plan.schema();
     let result = exprs
@@ -953,8 +953,8 @@ pub(crate) fn find_column_indexes_referenced_by_expr(
     indexes
 }
 
-/// can this data type be used in hash join equal conditions??
-/// data types here come from function 'equal_rows', if more data types are 
supported
+/// Can this data type be used in hash join equal conditions??
+/// Data types here come from function 'equal_rows', if more data types are 
supported
 /// in equal_rows(hash join), add those data types here to generate join 
logical plan.
 pub fn can_hash(data_type: &DataType) -> bool {
     match data_type {
diff --git a/datafusion/expr/src/window_state.rs 
b/datafusion/expr/src/window_state.rs
index e7f31bbfbf..f1d0ead23a 100644
--- a/datafusion/expr/src/window_state.rs
+++ b/datafusion/expr/src/window_state.rs
@@ -48,7 +48,7 @@ pub struct WindowAggState {
     /// Keeps track of how many rows should be generated to be in sync with 
input record_batch.
     // (For each row in the input record batch we need to generate a window 
result).
     pub n_row_result_missing: usize,
-    /// flag indicating whether we have received all data for this partition
+    /// Flag indicating whether we have received all data for this partition
     pub is_end: bool,
 }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to