Skip to content

Apache DataFusion SQL Query Engine

chore: Format examples in doc strings - expr (#18340)

Yu-Chuan Hung4e0596d0d7a7
diff --git a/datafusion/expr-common/src/interval_arithmetic.rs b/datafusion/expr-common/src/interval_arithmetic.rs
index b5b632076b..40c44cfb3c 100644
--- a/datafusion/expr-common/src/interval_arithmetic.rs
+++ b/datafusion/expr-common/src/interval_arithmetic.rs
@@ -1670,22 +1670,23 @@ fn cast_scalar_value(
///
/// // [1, 2) U {NULL}
/// let maybe_null = NullableInterval::MaybeNull {
-/// values: Interval::try_new(
-/// ScalarValue::Int32(Some(1)),
-/// ScalarValue::Int32(Some(2)),
-/// ).unwrap(),
+/// values: Interval::try_new(
+/// ScalarValue::Int32(Some(1)),
+/// ScalarValue::Int32(Some(2)),
+/// )
+/// .unwrap(),
/// };
///
/// // (0, ∞)
/// let not_null = NullableInterval::NotNull {
-/// values: Interval::try_new(
-/// ScalarValue::Int32(Some(0)),
-/// ScalarValue::Int32(None),
-/// ).unwrap(),
+/// values: Interval::try_new(ScalarValue::Int32(Some(0)), ScalarValue::Int32(None))
+/// .unwrap(),
/// };
///
/// // {NULL}
-/// let null_interval = NullableInterval::Null { datatype: DataType::Int32 };
+/// let null_interval = NullableInterval::Null {
+/// datatype: DataType::Int32,
+/// };
///
/// // {4}
/// let single_value = NullableInterval::from(ScalarValue::Int32(Some(4)));
@@ -1787,22 +1788,26 @@ impl NullableInterval {
///
/// ```
/// use datafusion_common::ScalarValue;
- /// use datafusion_expr_common::operator::Operator;
/// use datafusion_expr_common::interval_arithmetic::Interval;
/// use datafusion_expr_common::interval_arithmetic::NullableInterval;
+ /// use datafusion_expr_common::operator::Operator;
///
/// // 4 > 3 -> true
/// let lhs = NullableInterval::from(ScalarValue::Int32(Some(4)));
/// let rhs = NullableInterval::from(ScalarValue::Int32(Some(3)));
/// let result = lhs.apply_operator(&Operator::Gt, &rhs).unwrap();
- /// assert_eq!(result, NullableInterval::from(ScalarValue::Boolean(Some(true))));
+ /// assert_eq!(
+ /// result,
+ /// NullableInterval::from(ScalarValue::Boolean(Some(true)))
+ /// );
///
/// // [1, 3) > NULL -> NULL
/// let lhs = NullableInterval::NotNull {
/// values: Interval::try_new(
- /// ScalarValue::Int32(Some(1)),
- /// ScalarValue::Int32(Some(3)),
- /// ).unwrap(),
+ /// ScalarValue::Int32(Some(1)),
+ /// ScalarValue::Int32(Some(3)),
+ /// )
+ /// .unwrap(),
/// };
/// let rhs = NullableInterval::from(ScalarValue::Int32(None));
/// let result = lhs.apply_operator(&Operator::Gt, &rhs).unwrap();
@@ -1811,22 +1816,27 @@ impl NullableInterval {
/// // [1, 3] > [2, 4] -> [false, true]
/// let lhs = NullableInterval::NotNull {
/// values: Interval::try_new(
- /// ScalarValue::Int32(Some(1)),
- /// ScalarValue::Int32(Some(3)),
- /// ).unwrap(),
+ /// ScalarValue::Int32(Some(1)),
+ /// ScalarValue::Int32(Some(3)),
+ /// )
+ /// .unwrap(),
/// };
/// let rhs = NullableInterval::NotNull {
- /// values: Interval::try_new(
- /// ScalarValue::Int32(Some(2)),
- /// ScalarValue::Int32(Some(4)),
- /// ).unwrap(),
+ /// values: Interval::try_new(
+ /// ScalarValue::Int32(Some(2)),
+ /// ScalarValue::Int32(Some(4)),
+ /// )
+ /// .unwrap(),
/// };
/// let result = lhs.apply_operator(&Operator::Gt, &rhs).unwrap();
/// // Both inputs are valid (non-null), so result must be non-null
- /// assert_eq!(result, NullableInterval::NotNull {
- /// // Uncertain whether inequality is true or false
- /// values: Interval::UNCERTAIN,
- /// });
+ /// assert_eq!(
+ /// result,
+ /// NullableInterval::NotNull {
+ /// // Uncertain whether inequality is true or false
+ /// values: Interval::UNCERTAIN,
+ /// }
+ /// );
/// ```
pub fn apply_operator(&self, op: &Operator, rhs: &Self) -> Result<Self> {
match op {
@@ -1924,7 +1934,8 @@ impl NullableInterval {
/// values: Interval::try_new(
/// ScalarValue::Int32(Some(1)),
/// ScalarValue::Int32(Some(4)),
- /// ).unwrap(),
+ /// )
+ /// .unwrap(),
/// };
/// assert_eq!(interval.single_value(), None);
/// ```
diff --git a/datafusion/expr-common/src/signature.rs b/datafusion/expr-common/src/signature.rs
index 38eef077c5..5cb7a17ee3 100644
--- a/datafusion/expr-common/src/signature.rs
+++ b/datafusion/expr-common/src/signature.rs
@@ -127,11 +127,10 @@ pub enum Arity {
/// ```
/// # use arrow::datatypes::DataType;
/// # use datafusion_expr_common::signature::{TypeSignature};
-/// // Declares the function must be invoked with a single argument of type `Utf8View`.
-/// // if a user calls the function with `Utf8` or `LargeUtf8`, DataFusion will
-/// // automatically add a cast to `Utf8View` during planning.
-/// let type_signature = TypeSignature::Exact(vec![DataType::Utf8View]);
-///
+/// // Declares the function must be invoked with a single argument of type `Utf8View`.
+/// // if a user calls the function with `Utf8` or `LargeUtf8`, DataFusion will
+/// // automatically add a cast to `Utf8View` during planning.
+/// let type_signature = TypeSignature::Exact(vec![DataType::Utf8View]);
/// ```
///
/// # Example: Timestamps
@@ -144,11 +143,11 @@ pub enum Arity {
/// # use arrow::datatypes::{DataType, TimeUnit};
/// # use datafusion_expr_common::signature::{TIMEZONE_WILDCARD, TypeSignature};
/// let type_signature = TypeSignature::Exact(vec![
-/// // A nanosecond precision timestamp with ANY timezone
-/// // matches Timestamp(Nanosecond, Some("+0:00"))
-/// // matches Timestamp(Nanosecond, Some("+5:00"))
-/// // does not match Timestamp(Nanosecond, None)
-/// DataType::Timestamp(TimeUnit::Nanosecond, Some(TIMEZONE_WILDCARD.into())),
+/// // A nanosecond precision timestamp with ANY timezone
+/// // matches Timestamp(Nanosecond, Some("+0:00"))
+/// // matches Timestamp(Nanosecond, Some("+5:00"))
+/// // does not match Timestamp(Nanosecond, None)
+/// DataType::Timestamp(TimeUnit::Nanosecond, Some(TIMEZONE_WILDCARD.into())),
/// ]);
/// ```
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
@@ -858,8 +857,8 @@ fn get_data_types(native_type: &NativeType) -> Vec<DataType> {
/// # Examples
///
/// ```
+/// use datafusion_common::types::{logical_binary, logical_string, NativeType};
/// use datafusion_expr_common::signature::{Coercion, TypeSignatureClass};
-/// use datafusion_common::types::{NativeType, logical_binary, logical_string};
///
/// // Exact coercion that only accepts timestamp types
/// let exact = Coercion::new_exact(TypeSignatureClass::Timestamp);
@@ -868,7 +867,7 @@ fn get_data_types(native_type: &NativeType) -> Vec<DataType> {
/// let implicit = Coercion::new_implicit(
/// TypeSignatureClass::Native(logical_string()),
/// vec![TypeSignatureClass::Native(logical_binary())],
-/// NativeType::String
+/// NativeType::String,
/// );
/// ```
///
@@ -1275,8 +1274,9 @@ impl Signature {
/// ```
/// # use datafusion_expr_common::signature::{Signature, Volatility};
/// # use arrow::datatypes::DataType;
- /// let sig = Signature::exact(vec![DataType::Int32, DataType::Utf8], Volatility::Immutable)
- /// .with_parameter_names(vec!["count".to_string(), "name".to_string()]);
+ /// let sig =
+ /// Signature::exact(vec![DataType::Int32, DataType::Utf8], Volatility::Immutable)
+ /// .with_parameter_names(vec!["count".to_string(), "name".to_string()]);
/// ```
///
/// # Errors
diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs
index 6077b3c1e5..94dcd2a861 100644
--- a/datafusion/expr/src/expr.rs
+++ b/datafusion/expr/src/expr.rs
@@ -164,11 +164,11 @@ impl From<sqlparser::ast::NullTreatment> for NullTreatment {
/// # use datafusion_expr::{lit, col, Operator, Expr};
/// // Use the `+` operator to add two columns together
/// let expr = col("c1") + col("c2");
-/// assert!(matches!(expr, Expr::BinaryExpr { ..} ));
+/// assert!(matches!(expr, Expr::BinaryExpr { .. }));
/// if let Expr::BinaryExpr(binary_expr) = expr {
-/// assert_eq!(*binary_expr.left, col("c1"));
-/// assert_eq!(*binary_expr.right, col("c2"));
-/// assert_eq!(binary_expr.op, Operator::Plus);
+/// assert_eq!(*binary_expr.left, col("c1"));
+/// assert_eq!(*binary_expr.right, col("c2"));
+/// assert_eq!(binary_expr.op, Operator::Plus);
/// }
/// ```
///
@@ -179,12 +179,12 @@ impl From<sqlparser::ast::NullTreatment> for NullTreatment {
/// # use datafusion_common::ScalarValue;
/// # use datafusion_expr::{lit, col, Operator, Expr};
/// let expr = col("c1").eq(lit(42_i32));
-/// assert!(matches!(expr, Expr::BinaryExpr { .. } ));
+/// assert!(matches!(expr, Expr::BinaryExpr { .. }));
/// if let Expr::BinaryExpr(binary_expr) = expr {
-/// assert_eq!(*binary_expr.left, col("c1"));
-/// let scalar = ScalarValue::Int32(Some(42));
-/// assert_eq!(*binary_expr.right, Expr::Literal(scalar, None));
-/// assert_eq!(binary_expr.op, Operator::Eq);
+/// assert_eq!(*binary_expr.left, col("c1"));
+/// let scalar = ScalarValue::Int32(Some(42));
+/// assert_eq!(*binary_expr.right, Expr::Literal(scalar, None));
+/// assert_eq!(binary_expr.op, Operator::Eq);
/// }
/// ```
///
@@ -197,22 +197,22 @@ impl From<sqlparser::ast::NullTreatment> for NullTreatment {
/// # use datafusion_expr::Expr;
/// // Create a schema c1(int, c2 float)
/// let arrow_schema = Schema::new(vec![
-/// Field::new("c1", DataType::Int32, false),
-/// Field::new("c2", DataType::Float64, false),
+/// Field::new("c1", DataType::Int32, false),
+/// Field::new("c2", DataType::Float64, false),
/// ]);
/// // DFSchema is a an Arrow schema with optional relation name
-/// let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema)
-/// .unwrap();
+/// let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema).unwrap();
///
/// // Form Vec<Expr> with an expression for each column in the schema
-/// let exprs: Vec<_> = df_schema.iter()
-/// .map(Expr::from)
-/// .collect();
-///
-/// assert_eq!(exprs, vec![
-/// Expr::from(Column::from_qualified_name("t1.c1")),
-/// Expr::from(Column::from_qualified_name("t1.c2")),
-/// ]);
+/// let exprs: Vec<_> = df_schema.iter().map(Expr::from).collect();
+///
+/// assert_eq!(
+/// exprs,
+/// vec![
+/// Expr::from(Column::from_qualified_name("t1.c1")),
+/// Expr::from(Column::from_qualified_name("t1.c2")),
+/// ]
+/// );
/// ```
///
/// # Examples: Displaying `Exprs`
@@ -273,12 +273,13 @@ impl From<sqlparser::ast::NullTreatment> for NullTreatment {
/// let mut scalars = HashSet::new();
/// // apply recursively visits all nodes in the expression tree
/// expr.apply(|e| {
-/// if let Expr::Literal(scalar, _) = e {
-/// scalars.insert(scalar);
-/// }
-/// // The return value controls whether to continue visiting the tree
-/// Ok(TreeNodeRecursion::Continue)
-/// }).unwrap();
+/// if let Expr::Literal(scalar, _) = e {
+/// scalars.insert(scalar);
+/// }
+/// // The return value controls whether to continue visiting the tree
+/// Ok(TreeNodeRecursion::Continue)
+/// })
+/// .unwrap();
/// // All subtrees have been visited and literals found
/// assert_eq!(scalars.len(), 2);
/// assert!(scalars.contains(&ScalarValue::Int32(Some(5))));
@@ -1640,7 +1641,6 @@ impl Expr {
/// let metadata = FieldMetadata::from(metadata);
/// let expr = col("foo").alias_with_metadata("bar", Some(metadata));
/// ```
- ///
pub fn alias_with_metadata(
self,
name: impl Into<String>,
@@ -1670,9 +1670,9 @@ impl Expr {
/// # use datafusion_common::metadata::FieldMetadata;
/// let metadata = HashMap::from([("key".to_string(), "value".to_string())]);
/// let metadata = FieldMetadata::from(metadata);
- /// let expr = col("foo").alias_qualified_with_metadata(Some("tbl"), "bar", Some(metadata));
+ /// let expr =
+ /// col("foo").alias_qualified_with_metadata(Some("tbl"), "bar", Some(metadata));
/// ```
- ///
pub fn alias_qualified_with_metadata(
self,
relation: Option<impl Into<TableReference>>,
diff --git a/datafusion/expr/src/expr_schema.rs b/datafusion/expr/src/expr_schema.rs
index 8c557a5630..9e8d6080b8 100644
--- a/datafusion/expr/src/expr_schema.rs
+++ b/datafusion/expr/src/expr_schema.rs
@@ -82,15 +82,17 @@ impl ExprSchemable for Expr {
/// # use std::collections::HashMap;
///
/// fn main() {
- /// let expr = col("c1") + col("c2");
- /// let schema = DFSchema::from_unqualified_fields(
- /// vec![
- /// Field::new("c1", DataType::Int32, true),
- /// Field::new("c2", DataType::Float32, true),
- /// ].into(),
- /// HashMap::new(),
- /// ).unwrap();
- /// assert_eq!("Float32", format!("{}", expr.get_type(&schema).unwrap()));
+ /// let expr = col("c1") + col("c2");
+ /// let schema = DFSchema::from_unqualified_fields(
+ /// vec![
+ /// Field::new("c1", DataType::Int32, true),
+ /// Field::new("c2", DataType::Float32, true),
+ /// ]
+ /// .into(),
+ /// HashMap::new(),
+ /// )
+ /// .unwrap();
+ /// assert_eq!("Float32", format!("{}", expr.get_type(&schema).unwrap()));
/// }
/// ```
///
@@ -734,7 +736,6 @@ impl Expr {
/// 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/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs
index a430add3f7..b9afd894d7 100644
--- a/datafusion/expr/src/logical_plan/builder.rs
+++ b/datafusion/expr/src/logical_plan/builder.rs
@@ -450,14 +450,13 @@ impl LogicalPlanBuilder {
/// # ])) as _;
/// # let table_source = Arc::new(LogicalTableSource::new(employee_schema));
/// // VALUES (1), (2)
- /// let input = LogicalPlanBuilder::values(vec![vec![lit(1)], vec![lit(2)]])?
- /// .build()?;
+ /// let input = LogicalPlanBuilder::values(vec![vec![lit(1)], vec![lit(2)]])?.build()?;
/// // INSERT INTO MyTable VALUES (1), (2)
/// let insert_plan = LogicalPlanBuilder::insert_into(
- /// input,
- /// "MyTable",
- /// table_source,
- /// InsertOp::Append,
+ /// input,
+ /// "MyTable",
+ /// table_source,
+ /// InsertOp::Append,
/// )?;
/// # Ok(())
/// # }
@@ -953,8 +952,8 @@ impl LogicalPlanBuilder {
/// // Form the expression `(left.a != right.a)` AND `(left.b != right.b)`
/// let exprs = vec![
/// col("left.a").eq(col("right.a")),
- /// col("left.b").not_eq(col("right.b"))
- /// ];
+ /// col("left.b").not_eq(col("right.b")),
+ /// ];
///
/// // Perform the equivalent of `left INNER JOIN right ON (a != a2 AND b != b2)`
/// // finding all pairs of rows from `left` and `right` where
diff --git a/datafusion/expr/src/logical_plan/display.rs b/datafusion/expr/src/logical_plan/display.rs
index ea08c223e8..b601263355 100644
--- a/datafusion/expr/src/logical_plan/display.rs
+++ b/datafusion/expr/src/logical_plan/display.rs
@@ -94,17 +94,17 @@ impl<'n> TreeNodeVisitor<'n> for IndentVisitor<'_, '_> {
/// `foo:Utf8;N` if `foo` is nullable.
///
/// ```
-/// use arrow::datatypes::{Field, Schema, DataType};
+/// use arrow::datatypes::{DataType, Field, Schema};
/// # use datafusion_expr::logical_plan::display_schema;
/// let schema = Schema::new(vec![
/// Field::new("id", DataType::Int32, false),
/// Field::new("first_name", DataType::Utf8, true),
-/// ]);
+/// ]);
///
-/// assert_eq!(
-/// "[id:Int32, first_name:Utf8;N]",
-/// format!("{}", display_schema(&schema))
-/// );
+/// assert_eq!(
+/// "[id:Int32, first_name:Utf8;N]",
+/// format!("{}", display_schema(&schema))
+/// );
/// ```
pub fn display_schema(schema: &Schema) -> impl fmt::Display + '_ {
struct Wrapper<'a>(&'a Schema);
diff --git a/datafusion/expr/src/logical_plan/extension.rs b/datafusion/expr/src/logical_plan/extension.rs
index a8ee788564..fe324d40fd 100644
--- a/datafusion/expr/src/logical_plan/extension.rs
+++ b/datafusion/expr/src/logical_plan/extension.rs
@@ -39,10 +39,10 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
/// # struct Dummy { }
///
/// # impl Dummy {
- /// // canonical boiler plate
- /// fn as_any(&self) -> &dyn Any {
- /// self
- /// }
+ /// // canonical boiler plate
+ /// fn as_any(&self) -> &dyn Any {
+ /// self
+ /// }
/// # }
/// ```
fn as_any(&self) -> &dyn Any;
@@ -131,18 +131,18 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
/// // User defined node that derives Hash
/// #[derive(Hash, Debug, PartialEq, Eq)]
/// struct MyNode {
- /// val: u64
+ /// val: u64,
/// }
///
/// // impl UserDefinedLogicalNode {
/// // ...
/// # impl MyNode {
- /// // Boiler plate to call the derived Hash impl
- /// fn dyn_hash(&self, state: &mut dyn std::hash::Hasher) {
+ /// // Boiler plate to call the derived Hash impl
+ /// fn dyn_hash(&self, state: &mut dyn std::hash::Hasher) {
/// use std::hash::Hash;
/// let mut s = state;
/// self.hash(&mut s);
- /// }
+ /// }
/// // }
/// # }
/// ```
@@ -169,19 +169,19 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
/// // User defined node that derives Eq
/// #[derive(Hash, Debug, PartialEq, Eq)]
/// struct MyNode {
- /// val: u64
+ /// val: u64,
/// }
///
/// // impl UserDefinedLogicalNode {
/// // ...
/// # impl MyNode {
- /// // Boiler plate to call the derived Eq impl
- /// fn dyn_eq(&self, other: &dyn UserDefinedLogicalNode) -> bool {
+ /// // Boiler plate to call the derived Eq impl
+ /// fn dyn_eq(&self, other: &dyn UserDefinedLogicalNode) -> bool {
/// match other.as_any().downcast_ref::<Self>() {
- /// Some(o) => self == o,
- /// None => false,
+ /// Some(o) => self == o,
+ /// None => false,
/// }
- /// }
+ /// }
/// // }
/// # }
/// ```
diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs
index 9541f35e30..0f0d81186d 100644
--- a/datafusion/expr/src/logical_plan/plan.rs
+++ b/datafusion/expr/src/logical_plan/plan.rs
@@ -203,7 +203,6 @@ pub use datafusion_common::{JoinConstraint, JoinType};
/// # Ok(())
/// # }
/// ```
-///
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
pub enum LogicalPlan {
/// Evaluates an arbitrary list of expressions (essentially a
@@ -1267,7 +1266,6 @@ impl LogicalPlan {
/// \n TableScan: t1",
/// plan.display_indent().to_string()
/// );
- ///
/// ```
pub fn with_param_values(
self,
@@ -1561,20 +1559,20 @@ impl LogicalPlan {
/// ```
///
/// ```
- /// use arrow::datatypes::{Field, Schema, DataType};
- /// use datafusion_expr::{lit, col, LogicalPlanBuilder, logical_plan::table_scan};
- /// let schema = Schema::new(vec![
- /// Field::new("id", DataType::Int32, false),
- /// ]);
- /// let plan = table_scan(Some("t1"), &schema, None).unwrap()
- /// .filter(col("id").eq(lit(5))).unwrap()
- /// .build().unwrap();
+ /// use arrow::datatypes::{DataType, Field, Schema};
+ /// use datafusion_expr::{col, lit, logical_plan::table_scan, LogicalPlanBuilder};
+ /// let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
+ /// let plan = table_scan(Some("t1"), &schema, None)
+ /// .unwrap()
+ /// .filter(col("id").eq(lit(5)))
+ /// .unwrap()
+ /// .build()
+ /// .unwrap();
///
/// // Format using display_indent
/// let display_string = format!("{}", plan.display_indent());
///
- /// assert_eq!("Filter: t1.id = Int32(5)\n TableScan: t1",
- /// display_string);
+ /// assert_eq!("Filter: t1.id = Int32(5)\n TableScan: t1", display_string);
/// ```
pub fn display_indent(&self) -> impl Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
@@ -1603,21 +1601,24 @@ impl LogicalPlan {
/// ```
///
/// ```
- /// use arrow::datatypes::{Field, Schema, DataType};
- /// use datafusion_expr::{lit, col, LogicalPlanBuilder, logical_plan::table_scan};
- /// let schema = Schema::new(vec![
- /// Field::new("id", DataType::Int32, false),
- /// ]);
- /// let plan = table_scan(Some("t1"), &schema, None).unwrap()
- /// .filter(col("id").eq(lit(5))).unwrap()
- /// .build().unwrap();
+ /// use arrow::datatypes::{DataType, Field, Schema};
+ /// use datafusion_expr::{col, lit, logical_plan::table_scan, LogicalPlanBuilder};
+ /// let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
+ /// let plan = table_scan(Some("t1"), &schema, None)
+ /// .unwrap()
+ /// .filter(col("id").eq(lit(5)))
+ /// .unwrap()
+ /// .build()
+ /// .unwrap();
///
/// // Format using display_indent_schema
/// let display_string = format!("{}", plan.display_indent_schema());
///
- /// assert_eq!("Filter: t1.id = Int32(5) [id:Int32]\
+ /// assert_eq!(
+ /// "Filter: t1.id = Int32(5) [id:Int32]\
/// \n TableScan: t1 [id:Int32]",
- /// display_string);
+ /// display_string
+ /// );
/// ```
pub fn display_indent_schema(&self) -> impl Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
@@ -1665,14 +1666,15 @@ impl LogicalPlan {
/// structure, and one with additional details such as schema.
///
/// ```
- /// use arrow::datatypes::{Field, Schema, DataType};
- /// use datafusion_expr::{lit, col, LogicalPlanBuilder, logical_plan::table_scan};
- /// let schema = Schema::new(vec![
- /// Field::new("id", DataType::Int32, false),
- /// ]);
- /// let plan = table_scan(Some("t1"), &schema, None).unwrap()
- /// .filter(col("id").eq(lit(5))).unwrap()
- /// .build().unwrap();
+ /// use arrow::datatypes::{DataType, Field, Schema};
+ /// use datafusion_expr::{col, lit, logical_plan::table_scan, LogicalPlanBuilder};
+ /// let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
+ /// let plan = table_scan(Some("t1"), &schema, None)
+ /// .unwrap()
+ /// .filter(col("id").eq(lit(5)))
+ /// .unwrap()
+ /// .build()
+ /// .unwrap();
///
/// // Format using display_graphviz
/// let graphviz_string = format!("{}", plan.display_graphviz());
@@ -1684,7 +1686,6 @@ impl LogicalPlan {
/// ```bash
/// dot -Tpdf < /tmp/example.dot > /tmp/example.pdf
/// ```
- ///
pub fn display_graphviz(&self) -> impl Display + '_ {
// Boilerplate structure to wrap LogicalPlan with something
// that that can be formatted
@@ -1723,13 +1724,13 @@ impl LogicalPlan {
/// Projection: id
/// ```
/// ```
- /// use arrow::datatypes::{Field, Schema, DataType};
- /// use datafusion_expr::{lit, col, LogicalPlanBuilder, logical_plan::table_scan};
- /// let schema = Schema::new(vec![
- /// Field::new("id", DataType::Int32, false),
- /// ]);
- /// let plan = table_scan(Some("t1"), &schema, None).unwrap()
- /// .build().unwrap();
+ /// use arrow::datatypes::{DataType, Field, Schema};
+ /// use datafusion_expr::{col, lit, logical_plan::table_scan, LogicalPlanBuilder};
+ /// let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
+ /// let plan = table_scan(Some("t1"), &schema, None)
+ /// .unwrap()
+ /// .build()
+ /// .unwrap();
///
/// // Format using display
/// let display_string = format!("{}", plan.display());
diff --git a/datafusion/expr/src/select_expr.rs b/datafusion/expr/src/select_expr.rs
index 039df20f39..bfec4c5844 100644
--- a/datafusion/expr/src/select_expr.rs
+++ b/datafusion/expr/src/select_expr.rs
@@ -44,10 +44,8 @@ use crate::{expr::WildcardOptions, Expr};
/// let wildcard = SelectExpr::Wildcard(WildcardOptions::default());
///
/// // SELECT mytable.*
-/// let qualified = SelectExpr::QualifiedWildcard(
-/// "mytable".into(),
-/// WildcardOptions::default()
-/// );
+/// let qualified =
+/// SelectExpr::QualifiedWildcard("mytable".into(), WildcardOptions::default());
///
/// // SELECT col1
/// let expr = SelectExpr::Expression(col("col1").into());
diff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rs
index c4cd8c006d..fd54bb13a6 100644
--- a/datafusion/expr/src/udf.rs
+++ b/datafusion/expr/src/udf.rs
@@ -568,7 +568,6 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send + Sync {
///
/// * `Some(ScalarUDF)` - A new instance of this function configured with the new settings
/// * `None` - If this function does not change with new configuration settings (the default)
- ///
fn with_updated_config(&self, _config: &ConfigOptions) -> Option<ScalarUDF> {
None
}
@@ -604,10 +603,10 @@ pub trait ScalarUDFImpl: Debug + DynEq + DynHash + Send + Sync {
/// # struct Example{}
/// # impl Example {
/// fn return_field_from_args(&self, args: ReturnFieldArgs) -> Result<FieldRef> {
- /// // report output is only nullable if any one of the arguments are nullable
- /// let nullable = args.arg_fields.iter().any(|f| f.is_nullable());
- /// let field = Arc::new(Field::new("ignored_name", DataType::Int32, true));
- /// Ok(field)
+ /// // report output is only nullable if any one of the arguments are nullable
+ /// let nullable = args.arg_fields.iter().any(|f| f.is_nullable());
+ /// let field = Arc::new(Field::new("ignored_name", DataType::Int32, true));
+ /// Ok(field)
/// }
/// # }
/// ```
diff --git a/datafusion/expr/src/utils.rs b/datafusion/expr/src/utils.rs
index 74ba99847f..cd733e0a13 100644
--- a/datafusion/expr/src/utils.rs
+++ b/datafusion/expr/src/utils.rs
@@ -890,7 +890,6 @@ pub fn check_all_columns_from_schema(
/// all referenced column of the right side is from the right schema.
/// 2. Or opposite. All referenced column of the left side is from the right schema,
/// and the right side is from the left schema.
-///
pub fn find_valid_equijoin_key_pair(
left_key: &Expr,
right_key: &Expr,
@@ -1034,10 +1033,7 @@ pub fn iter_conjunction_owned(expr: Expr) -> impl Iterator<Item = Expr> {
/// let expr = col("a").eq(lit(1)).and(col("b").eq(lit(2)));
///
/// // [a=1, b=2]
-/// let split = vec![
-/// col("a").eq(lit(1)),
-/// col("b").eq(lit(2)),
-/// ];
+/// let split = vec![col("a").eq(lit(1)), col("b").eq(lit(2))];
///
/// // use split_conjunction_owned to split them
/// assert_eq!(split_conjunction_owned(expr), split);
@@ -1060,10 +1056,7 @@ pub fn split_conjunction_owned(expr: Expr) -> Vec<Expr> {
/// let expr = col("a").eq(lit(1)).add(col("b").eq(lit(2)));
///
/// // [a=1, b=2]
-/// let split = vec![
-/// col("a").eq(lit(1)),
-/// col("b").eq(lit(2)),
-/// ];
+/// let split = vec![col("a").eq(lit(1)), col("b").eq(lit(2))];
///
/// // use split_binary_owned to split them
/// assert_eq!(split_binary_owned(expr, Operator::Plus), split);
@@ -1131,10 +1124,7 @@ fn split_binary_impl<'a>(
/// let expr = col("a").eq(lit(1)).and(col("b").eq(lit(2)));
///
/// // [a=1, b=2]
-/// let split = vec![
-/// col("a").eq(lit(1)),
-/// col("b").eq(lit(2)),
-/// ];
+/// let split = vec![col("a").eq(lit(1)), col("b").eq(lit(2))];
///
/// // use conjunction to join them together with `AND`
/// assert_eq!(conjunction(split), Some(expr));
@@ -1157,10 +1147,7 @@ pub fn conjunction(filters: impl IntoIterator<Item = Expr>) -> Option<Expr> {
/// let expr = col("a").eq(lit(1)).or(col("b").eq(lit(2)));
///
/// // [a=1, b=2]
-/// let split = vec![
-/// col("a").eq(lit(1)),
-/// col("b").eq(lit(2)),
-/// ];
+/// let split = vec![col("a").eq(lit(1)), col("b").eq(lit(2))];
///
/// // use disjunction to join them together with `OR`
/// assert_eq!(disjunction(split), Some(expr));
diff --git a/datafusion/expr/src/window_frame.rs b/datafusion/expr/src/window_frame.rs
index f72dc10a69..5fb2916c34 100644
--- a/datafusion/expr/src/window_frame.rs
+++ b/datafusion/expr/src/window_frame.rs
@@ -307,7 +307,6 @@ impl WindowFrame {
/// 3. CURRENT ROW
/// 4. `<expr>` FOLLOWING
/// 5. UNBOUNDED FOLLOWING
-///
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash)]
pub enum WindowFrameBound {
/// 1. UNBOUNDED PRECEDING