Apache DataFusion SQL Query Engine
fix: Remove datafusion-macros's dependency on datafusion-expr (#17688)
Hiroaki Yutanid5bfcf515db2
diff --git a/Cargo.lock b/Cargo.lockindex 1425cd0bef..2c00f0339d 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2359,7 +2359,7 @@ dependencies = [name = "datafusion-macros"version = "50.0.0"dependencies = [- "datafusion-expr",+ "datafusion-doc","quote","syn 2.0.106",]diff --git a/datafusion/doc/src/lib.rs b/datafusion/doc/src/lib.rsindex 9a2c5656ba..943be7a71c 100644--- a/datafusion/doc/src/lib.rs+++ b/datafusion/doc/src/lib.rs@@ -21,6 +21,14 @@)]#![cfg_attr(docsrs, feature(doc_auto_cfg))]+mod udaf;+mod udf;+mod udwf;++pub use udaf::aggregate_doc_sections;+pub use udf::scalar_doc_sections;+pub use udwf::window_doc_sections;+#[allow(rustdoc::broken_intra_doc_links)]/// Documentation for use by [`ScalarUDFImpl`](ScalarUDFImpl),/// [`AggregateUDFImpl`](AggregateUDFImpl) and [`WindowUDFImpl`](WindowUDFImpl) functions.diff --git a/datafusion/doc/src/udaf.rs b/datafusion/doc/src/udaf.rsnew file mode 100644index 0000000000..c3a0b4adbc--- /dev/null+++ b/datafusion/doc/src/udaf.rs@@ -0,0 +1,47 @@+// Licensed to the Apache Software Foundation (ASF) under one+// or more contributor license agreements. See the NOTICE file+// distributed with this work for additional information+// regarding copyright ownership. The ASF licenses this file+// to you under the Apache License, Version 2.0 (the+// "License"); you may not use this file except in compliance+// with the License. You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing,+// software distributed under the License is distributed on an+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+// KIND, either express or implied. See the License for the+// specific language governing permissions and limitations+// under the License.++// Aggregate UDF doc sections for use in public documentation+pub mod aggregate_doc_sections {+ use crate::DocSection;++ pub fn doc_sections() -> Vec<DocSection> {+ vec![+ DOC_SECTION_GENERAL,+ DOC_SECTION_STATISTICAL,+ DOC_SECTION_APPROXIMATE,+ ]+ }++ pub const DOC_SECTION_GENERAL: DocSection = DocSection {+ include: true,+ label: "General Functions",+ description: None,+ };++ pub const DOC_SECTION_STATISTICAL: DocSection = DocSection {+ include: true,+ label: "Statistical Functions",+ description: None,+ };++ pub const DOC_SECTION_APPROXIMATE: DocSection = DocSection {+ include: true,+ label: "Approximate Functions",+ description: None,+ };+}diff --git a/datafusion/doc/src/udf.rs b/datafusion/doc/src/udf.rsnew file mode 100644index 0000000000..3d18c9ac27--- /dev/null+++ b/datafusion/doc/src/udf.rs@@ -0,0 +1,132 @@+// Licensed to the Apache Software Foundation (ASF) under one+// or more contributor license agreements. See the NOTICE file+// distributed with this work for additional information+// regarding copyright ownership. The ASF licenses this file+// to you under the Apache License, Version 2.0 (the+// "License"); you may not use this file except in compliance+// with the License. You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing,+// software distributed under the License is distributed on an+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+// KIND, either express or implied. See the License for the+// specific language governing permissions and limitations+// under the License.++// Scalar UDF doc sections for use in public documentation+pub mod scalar_doc_sections {+ use crate::DocSection;++ pub fn doc_sections() -> Vec<DocSection> {+ vec![+ DOC_SECTION_MATH,+ DOC_SECTION_CONDITIONAL,+ DOC_SECTION_STRING,+ DOC_SECTION_BINARY_STRING,+ DOC_SECTION_REGEX,+ DOC_SECTION_DATETIME,+ DOC_SECTION_ARRAY,+ DOC_SECTION_STRUCT,+ DOC_SECTION_MAP,+ DOC_SECTION_HASHING,+ DOC_SECTION_UNION,+ DOC_SECTION_OTHER,+ ]+ }++ pub const fn doc_sections_const() -> &'static [DocSection] {+ &[+ DOC_SECTION_MATH,+ DOC_SECTION_CONDITIONAL,+ DOC_SECTION_STRING,+ DOC_SECTION_BINARY_STRING,+ DOC_SECTION_REGEX,+ DOC_SECTION_DATETIME,+ DOC_SECTION_ARRAY,+ DOC_SECTION_STRUCT,+ DOC_SECTION_MAP,+ DOC_SECTION_HASHING,+ DOC_SECTION_UNION,+ DOC_SECTION_OTHER,+ ]+ }++ pub const DOC_SECTION_MATH: DocSection = DocSection {+ include: true,+ label: "Math Functions",+ description: None,+ };++ pub const DOC_SECTION_CONDITIONAL: DocSection = DocSection {+ include: true,+ label: "Conditional Functions",+ description: None,+ };++ pub const DOC_SECTION_STRING: DocSection = DocSection {+ include: true,+ label: "String Functions",+ description: None,+ };++ pub const DOC_SECTION_BINARY_STRING: DocSection = DocSection {+ include: true,+ label: "Binary String Functions",+ description: None,+ };++ pub const DOC_SECTION_REGEX: DocSection = DocSection {+ include: true,+ label: "Regular Expression Functions",+ description: Some(+ r#"Apache DataFusion uses a [PCRE-like](https://en.wikibooks.org/wiki/Regular_Expressions/Perl-Compatible_Regular_Expressions)+regular expression [syntax](https://docs.rs/regex/latest/regex/#syntax)+(minus support for several features including look-around and backreferences).+The following regular expression functions are supported:"#,+ ),+ };++ pub const DOC_SECTION_DATETIME: DocSection = DocSection {+ include: true,+ label: "Time and Date Functions",+ description: None,+ };++ pub const DOC_SECTION_ARRAY: DocSection = DocSection {+ include: true,+ label: "Array Functions",+ description: None,+ };++ pub const DOC_SECTION_STRUCT: DocSection = DocSection {+ include: true,+ label: "Struct Functions",+ description: None,+ };++ pub const DOC_SECTION_MAP: DocSection = DocSection {+ include: true,+ label: "Map Functions",+ description: None,+ };++ pub const DOC_SECTION_HASHING: DocSection = DocSection {+ include: true,+ label: "Hashing Functions",+ description: None,+ };++ pub const DOC_SECTION_OTHER: DocSection = DocSection {+ include: true,+ label: "Other Functions",+ description: None,+ };++ pub const DOC_SECTION_UNION: DocSection = DocSection {+ include: true,+ label: "Union Functions",+ description: Some("Functions to work with the union data type, also know as tagged unions, variant types, enums or sum types. Note: Not related to the SQL UNION operator"),+ };+}diff --git a/datafusion/doc/src/udwf.rs b/datafusion/doc/src/udwf.rsnew file mode 100644index 0000000000..0257ce5ba6--- /dev/null+++ b/datafusion/doc/src/udwf.rs@@ -0,0 +1,47 @@+// Licensed to the Apache Software Foundation (ASF) under one+// or more contributor license agreements. See the NOTICE file+// distributed with this work for additional information+// regarding copyright ownership. The ASF licenses this file+// to you under the Apache License, Version 2.0 (the+// "License"); you may not use this file except in compliance+// with the License. You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing,+// software distributed under the License is distributed on an+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+// KIND, either express or implied. See the License for the+// specific language governing permissions and limitations+// under the License.++// Window UDF doc sections for use in public documentation+pub mod window_doc_sections {+ use crate::DocSection;++ pub fn doc_sections() -> Vec<DocSection> {+ vec![+ DOC_SECTION_AGGREGATE,+ DOC_SECTION_RANKING,+ DOC_SECTION_ANALYTICAL,+ ]+ }++ pub const DOC_SECTION_AGGREGATE: DocSection = DocSection {+ include: true,+ label: "Aggregate Functions",+ description: Some("All aggregate functions can be used as window functions."),+ };++ pub const DOC_SECTION_RANKING: DocSection = DocSection {+ include: true,+ label: "Ranking Functions",+ description: None,+ };++ pub const DOC_SECTION_ANALYTICAL: DocSection = DocSection {+ include: true,+ label: "Analytical Functions",+ description: None,+ };+}diff --git a/datafusion/expr/src/lib.rs b/datafusion/expr/src/lib.rsindex 929d0664b4..d525ade2c3 100644--- a/datafusion/expr/src/lib.rs+++ b/datafusion/expr/src/lib.rs@@ -79,7 +79,10 @@ pub mod var_provider;pub mod window_frame;pub mod window_state;-pub use datafusion_doc::{DocSection, Documentation, DocumentationBuilder};+pub use datafusion_doc::{+ aggregate_doc_sections, scalar_doc_sections, window_doc_sections, DocSection,+ Documentation, DocumentationBuilder,+};pub use datafusion_expr_common::accumulator::Accumulator;pub use datafusion_expr_common::columnar_value::ColumnarValue;pub use datafusion_expr_common::groups_accumulator::{EmitTo, GroupsAccumulator};@@ -108,15 +111,13 @@ pub use partition_evaluator::PartitionEvaluator;pub use sqlparser;pub use table_source::{TableProviderFilterPushDown, TableSource, TableType};pub use udaf::{- aggregate_doc_sections, 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,-};-pub use udf::{- scalar_doc_sections, ReturnFieldArgs, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl,+ 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,};-pub use udwf::{window_doc_sections, ReversedUDWF, WindowUDF, WindowUDFImpl};+pub use udf::{ReturnFieldArgs, ScalarFunctionArgs, ScalarUDF, ScalarUDFImpl};+pub use udwf::{ReversedUDWF, WindowUDF, WindowUDFImpl};pub use window_frame::{WindowFrame, WindowFrameBound, WindowFrameUnits};#[cfg(test)]diff --git a/datafusion/expr/src/udaf.rs b/datafusion/expr/src/udaf.rsindex 2243682cfd..288e79ec1e 100644--- a/datafusion/expr/src/udaf.rs+++ b/datafusion/expr/src/udaf.rs@@ -1221,37 +1221,6 @@ impl AggregateUDFImpl for AliasedAggregateUDFImpl {}}-// Aggregate UDF doc sections for use in public documentation-pub mod aggregate_doc_sections {- use crate::DocSection;-- pub fn doc_sections() -> Vec<DocSection> {- vec![- DOC_SECTION_GENERAL,- DOC_SECTION_STATISTICAL,- DOC_SECTION_APPROXIMATE,- ]- }-- pub const DOC_SECTION_GENERAL: DocSection = DocSection {- include: true,- label: "General Functions",- description: None,- };-- pub const DOC_SECTION_STATISTICAL: DocSection = DocSection {- include: true,- label: "Statistical Functions",- description: None,- };-- pub const DOC_SECTION_APPROXIMATE: DocSection = DocSection {- include: true,- label: "Approximate Functions",- description: None,- };-}-/// Indicates whether an aggregation function is monotonic as a set/// function. A set function is monotonically increasing if its value/// increases as its argument grows (as a set). Formally, `f` is adiff --git a/datafusion/expr/src/udf.rs b/datafusion/expr/src/udf.rsindex 758c6b5f2f..bc9e62fe62 100644--- a/datafusion/expr/src/udf.rs+++ b/datafusion/expr/src/udf.rs@@ -870,122 +870,6 @@ impl ScalarUDFImpl for AliasedScalarUDFImpl {}}-// Scalar UDF doc sections for use in public documentation-pub mod scalar_doc_sections {- use crate::DocSection;-- pub fn doc_sections() -> Vec<DocSection> {- vec![- DOC_SECTION_MATH,- DOC_SECTION_CONDITIONAL,- DOC_SECTION_STRING,- DOC_SECTION_BINARY_STRING,- DOC_SECTION_REGEX,- DOC_SECTION_DATETIME,- DOC_SECTION_ARRAY,- DOC_SECTION_STRUCT,- DOC_SECTION_MAP,- DOC_SECTION_HASHING,- DOC_SECTION_UNION,- DOC_SECTION_OTHER,- ]- }-- pub const fn doc_sections_const() -> &'static [DocSection] {- &[- DOC_SECTION_MATH,- DOC_SECTION_CONDITIONAL,- DOC_SECTION_STRING,- DOC_SECTION_BINARY_STRING,- DOC_SECTION_REGEX,- DOC_SECTION_DATETIME,- DOC_SECTION_ARRAY,- DOC_SECTION_STRUCT,- DOC_SECTION_MAP,- DOC_SECTION_HASHING,- DOC_SECTION_UNION,- DOC_SECTION_OTHER,- ]- }-- pub const DOC_SECTION_MATH: DocSection = DocSection {- include: true,- label: "Math Functions",- description: None,- };-- pub const DOC_SECTION_CONDITIONAL: DocSection = DocSection {- include: true,- label: "Conditional Functions",- description: None,- };-- pub const DOC_SECTION_STRING: DocSection = DocSection {- include: true,- label: "String Functions",- description: None,- };-- pub const DOC_SECTION_BINARY_STRING: DocSection = DocSection {- include: true,- label: "Binary String Functions",- description: None,- };-- pub const DOC_SECTION_REGEX: DocSection = DocSection {- include: true,- label: "Regular Expression Functions",- description: Some(- r#"Apache DataFusion uses a [PCRE-like](https://en.wikibooks.org/wiki/Regular_Expressions/Perl-Compatible_Regular_Expressions)-regular expression [syntax](https://docs.rs/regex/latest/regex/#syntax)-(minus support for several features including look-around and backreferences).-The following regular expression functions are supported:"#,- ),- };-- pub const DOC_SECTION_DATETIME: DocSection = DocSection {- include: true,- label: "Time and Date Functions",- description: None,- };-- pub const DOC_SECTION_ARRAY: DocSection = DocSection {- include: true,- label: "Array Functions",- description: None,- };-- pub const DOC_SECTION_STRUCT: DocSection = DocSection {- include: true,- label: "Struct Functions",- description: None,- };-- pub const DOC_SECTION_MAP: DocSection = DocSection {- include: true,- label: "Map Functions",- description: None,- };-- pub const DOC_SECTION_HASHING: DocSection = DocSection {- include: true,- label: "Hashing Functions",- description: None,- };-- pub const DOC_SECTION_OTHER: DocSection = DocSection {- include: true,- label: "Other Functions",- description: None,- };-- pub const DOC_SECTION_UNION: DocSection = DocSection {- include: true,- label: "Union Functions",- description: Some("Functions to work with the union data type, also know as tagged unions, variant types, enums or sum types. Note: Not related to the SQL UNION operator"),- };-}-#[cfg(test)]mod tests {use super::*;diff --git a/datafusion/expr/src/udwf.rs b/datafusion/expr/src/udwf.rsindex a7b4302dd8..402add0391 100644--- a/datafusion/expr/src/udwf.rs+++ b/datafusion/expr/src/udwf.rs@@ -525,37 +525,6 @@ impl WindowUDFImpl for AliasedWindowUDFImpl {}}-// Window UDF doc sections for use in public documentation-pub mod window_doc_sections {- use datafusion_doc::DocSection;-- pub fn doc_sections() -> Vec<DocSection> {- vec![- DOC_SECTION_AGGREGATE,- DOC_SECTION_RANKING,- DOC_SECTION_ANALYTICAL,- ]- }-- pub const DOC_SECTION_AGGREGATE: DocSection = DocSection {- include: true,- label: "Aggregate Functions",- description: Some("All aggregate functions can be used as window functions."),- };-- pub const DOC_SECTION_RANKING: DocSection = DocSection {- include: true,- label: "Ranking Functions",- description: None,- };-- pub const DOC_SECTION_ANALYTICAL: DocSection = DocSection {- include: true,- label: "Analytical Functions",- description: None,- };-}-#[cfg(test)]mod test {use crate::{PartitionEvaluator, WindowUDF, WindowUDFImpl};diff --git a/datafusion/functions-aggregate/src/bit_and_or_xor.rs b/datafusion/functions-aggregate/src/bit_and_or_xor.rsindex 4926b248c0..e63044c753 100644--- a/datafusion/functions-aggregate/src/bit_and_or_xor.rs+++ b/datafusion/functions-aggregate/src/bit_and_or_xor.rs@@ -40,7 +40,7 @@ use datafusion_expr::{Signature, Volatility,};-use datafusion_expr::aggregate_doc_sections::DOC_SECTION_GENERAL;+use datafusion_doc::aggregate_doc_sections::DOC_SECTION_GENERAL;use datafusion_functions_aggregate_common::aggregate::groups_accumulator::prim_op::PrimitiveGroupsAccumulator;use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign};use std::sync::LazyLock;diff --git a/datafusion/functions-aggregate/src/regr.rs b/datafusion/functions-aggregate/src/regr.rsindex 77bb04bf2c..44ce0bd48e 100644--- a/datafusion/functions-aggregate/src/regr.rs+++ b/datafusion/functions-aggregate/src/regr.rs@@ -29,7 +29,7 @@ use datafusion_common::{downcast_value, plan_err, unwrap_or_internal_err, DataFusionError, HashMap, Result,ScalarValue,};-use datafusion_expr::aggregate_doc_sections::DOC_SECTION_STATISTICAL;+use datafusion_doc::aggregate_doc_sections::DOC_SECTION_STATISTICAL;use datafusion_expr::function::{AccumulatorArgs, StateFieldsArgs};use datafusion_expr::type_coercion::aggregates::NUMERICS;use datafusion_expr::utils::format_state_name;diff --git a/datafusion/functions-window/src/lead_lag.rs b/datafusion/functions-window/src/lead_lag.rsindex 7950cc93f8..c4cbc268cd 100644--- a/datafusion/functions-window/src/lead_lag.rs+++ b/datafusion/functions-window/src/lead_lag.rs@@ -23,7 +23,7 @@ use datafusion_common::arrow::array::ArrayRef;use datafusion_common::arrow::datatypes::DataType;use datafusion_common::arrow::datatypes::Field;use datafusion_common::{arrow_datafusion_err, DataFusionError, Result, ScalarValue};-use datafusion_expr::window_doc_sections::DOC_SECTION_ANALYTICAL;+use datafusion_doc::window_doc_sections::DOC_SECTION_ANALYTICAL;use datafusion_expr::{Documentation, Literal, PartitionEvaluator, ReversedUDWF, Signature, TypeSignature,Volatility, WindowUDFImpl,diff --git a/datafusion/functions-window/src/nth_value.rs b/datafusion/functions-window/src/nth_value.rsindex 309978e9e7..02beeec4ec 100644--- a/datafusion/functions-window/src/nth_value.rs+++ b/datafusion/functions-window/src/nth_value.rs@@ -23,7 +23,7 @@ use arrow::datatypes::FieldRef;use datafusion_common::arrow::array::ArrayRef;use datafusion_common::arrow::datatypes::{DataType, Field};use datafusion_common::{exec_datafusion_err, exec_err, Result, ScalarValue};-use datafusion_expr::window_doc_sections::DOC_SECTION_ANALYTICAL;+use datafusion_doc::window_doc_sections::DOC_SECTION_ANALYTICAL;use datafusion_expr::window_state::WindowAggState;use datafusion_expr::{Documentation, Literal, PartitionEvaluator, ReversedUDWF, Signature, TypeSignature,diff --git a/datafusion/functions-window/src/rank.rs b/datafusion/functions-window/src/rank.rsindex bc88572a92..51ec4bbdbf 100644--- a/datafusion/functions-window/src/rank.rs+++ b/datafusion/functions-window/src/rank.rs@@ -27,7 +27,7 @@ use datafusion_common::arrow::datatypes::DataType;use datafusion_common::arrow::datatypes::Field;use datafusion_common::utils::get_row_at_idx;use datafusion_common::{exec_err, Result, ScalarValue};-use datafusion_expr::window_doc_sections::DOC_SECTION_RANKING;+use datafusion_doc::window_doc_sections::DOC_SECTION_RANKING;use datafusion_expr::{Documentation, PartitionEvaluator, Signature, Volatility, WindowUDFImpl,};diff --git a/datafusion/functions/src/math/monotonicity.rs b/datafusion/functions/src/math/monotonicity.rsindex 7870dc9562..5b8252137b 100644--- a/datafusion/functions/src/math/monotonicity.rs+++ b/datafusion/functions/src/math/monotonicity.rs@@ -18,8 +18,8 @@use std::sync::LazyLock;use datafusion_common::{exec_err, Result, ScalarValue};+use datafusion_doc::scalar_doc_sections::DOC_SECTION_MATH;use datafusion_expr::interval_arithmetic::Interval;-use datafusion_expr::scalar_doc_sections::DOC_SECTION_MATH;use datafusion_expr::sort_properties::{ExprProperties, SortProperties};use datafusion_expr::Documentation;diff --git a/datafusion/macros/Cargo.toml b/datafusion/macros/Cargo.tomlindex 16be6f5c67..7bd0c68e15 100644--- a/datafusion/macros/Cargo.toml+++ b/datafusion/macros/Cargo.toml@@ -41,6 +41,6 @@ path = "src/user_doc.rs"proc-macro = true[dependencies]-datafusion-expr = { workspace = true }+datafusion-doc = { workspace = true }quote = "1.0.40"syn = { version = "2.0.106", features = ["full"] }diff --git a/datafusion/macros/src/user_doc.rs b/datafusion/macros/src/user_doc.rsindex 31cf9bb1b7..90e4e47485 100644--- a/datafusion/macros/src/user_doc.rs+++ b/datafusion/macros/src/user_doc.rs@@ -22,7 +22,7 @@#![cfg_attr(docsrs, feature(doc_auto_cfg))]extern crate proc_macro;-use datafusion_expr::scalar_doc_sections::doc_sections_const;+use datafusion_doc::scalar_doc_sections::doc_sections_const;use proc_macro::TokenStream;use quote::quote;use syn::{parse_macro_input, DeriveInput, LitStr};