Skip to content

Commit e99e02b

Browse files
authored
Fix recursive-protection feature flag (#13887)
* Fix recursive-protection feature flag * rename feature flag to be consistent * Make default * taplo format
1 parent 901a094 commit e99e02b

File tree

22 files changed

+108
-36
lines changed

22 files changed

+108
-36
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Default features:
113113
- `regex_expressions`: regular expression functions, such as `regexp_match`
114114
- `unicode_expressions`: Include unicode aware functions such as `character_length`
115115
- `unparser`: enables support to reverse LogicalPlans back into SQL
116-
- `recursive-protection`: uses [recursive](https://docs.rs/recursive/latest/recursive/) for stack overflow protection.
116+
- `recursive_protection`: uses [recursive](https://docs.rs/recursive/latest/recursive/) for stack overflow protection.
117117

118118
Optional features:
119119

datafusion-cli/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ datafusion = { path = "../datafusion/core", version = "43.0.0", features = [
4545
"datetime_expressions",
4646
"encoding_expressions",
4747
"parquet",
48+
"recursive_protection",
4849
"regex_expressions",
4950
"unicode_expressions",
5051
"compression",

datafusion/common/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ name = "datafusion_common"
3636
path = "src/lib.rs"
3737

3838
[features]
39-
default = ["recursive-protection"]
4039
avro = ["apache-avro"]
4140
backtrace = []
4241
pyarrow = ["pyo3", "arrow/pyarrow", "parquet"]
4342
force_hash_collisions = []
44-
recursive-protection = ["dep:recursive"]
43+
recursive_protection = ["dep:recursive"]
4544

4645
[dependencies]
4746
ahash = { workspace = true }

datafusion/common/src/tree_node.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub trait TreeNode: Sized {
124124
/// TreeNodeVisitor::f_up(ChildNode2)
125125
/// TreeNodeVisitor::f_up(ParentNode)
126126
/// ```
127-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
127+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
128128
fn visit<'n, V: TreeNodeVisitor<'n, Node = Self>>(
129129
&'n self,
130130
visitor: &mut V,
@@ -174,7 +174,7 @@ pub trait TreeNode: Sized {
174174
/// TreeNodeRewriter::f_up(ChildNode2)
175175
/// TreeNodeRewriter::f_up(ParentNode)
176176
/// ```
177-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
177+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
178178
fn rewrite<R: TreeNodeRewriter<Node = Self>>(
179179
self,
180180
rewriter: &mut R,
@@ -197,7 +197,7 @@ pub trait TreeNode: Sized {
197197
&'n self,
198198
mut f: F,
199199
) -> Result<TreeNodeRecursion> {
200-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
200+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
201201
fn apply_impl<'n, N: TreeNode, F: FnMut(&'n N) -> Result<TreeNodeRecursion>>(
202202
node: &'n N,
203203
f: &mut F,
@@ -232,7 +232,7 @@ pub trait TreeNode: Sized {
232232
self,
233233
mut f: F,
234234
) -> Result<Transformed<Self>> {
235-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
235+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
236236
fn transform_down_impl<N: TreeNode, F: FnMut(N) -> Result<Transformed<N>>>(
237237
node: N,
238238
f: &mut F,
@@ -256,7 +256,7 @@ pub trait TreeNode: Sized {
256256
self,
257257
mut f: F,
258258
) -> Result<Transformed<Self>> {
259-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
259+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
260260
fn transform_up_impl<N: TreeNode, F: FnMut(N) -> Result<Transformed<N>>>(
261261
node: N,
262262
f: &mut F,
@@ -371,7 +371,7 @@ pub trait TreeNode: Sized {
371371
mut f_down: FD,
372372
mut f_up: FU,
373373
) -> Result<Transformed<Self>> {
374-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
374+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
375375
fn transform_down_up_impl<
376376
N: TreeNode,
377377
FD: FnMut(N) -> Result<Transformed<N>>,
@@ -2349,7 +2349,7 @@ pub(crate) mod tests {
23492349
Ok(())
23502350
}
23512351

2352-
#[cfg(feature = "recursive-protection")]
2352+
#[cfg(feature = "recursive_protection")]
23532353
#[test]
23542354
fn test_large_tree() {
23552355
let mut item = TestTreeNode::new_leaf("initial".to_string());

datafusion/core/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ default = [
5959
"unicode_expressions",
6060
"compression",
6161
"parquet",
62+
"recursive_protection",
6263
]
6364
encoding_expressions = ["datafusion-functions/encoding_expressions"]
6465
# Used for testing ONLY: causes all values to hash to the same value (test for collisions)
@@ -69,6 +70,13 @@ pyarrow = ["datafusion-common/pyarrow", "parquet"]
6970
regex_expressions = [
7071
"datafusion-functions/regex_expressions",
7172
]
73+
recursive_protection = [
74+
"datafusion-common/recursive_protection",
75+
"datafusion-expr/recursive_protection",
76+
"datafusion-optimizer/recursive_protection",
77+
"datafusion-physical-optimizer/recursive_protection",
78+
"datafusion-sql/recursive_protection",
79+
]
7280
serde = ["arrow-schema/serde"]
7381
string_expressions = ["datafusion-functions/string_expressions"]
7482
unicode_expressions = [

datafusion/expr/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ name = "datafusion_expr"
3636
path = "src/lib.rs"
3737

3838
[features]
39-
default = ["recursive-protection"]
40-
recursive-protection = ["dep:recursive"]
39+
recursive_protection = ["dep:recursive"]
4140

4241
[dependencies]
4342
arrow = { workspace = true }

datafusion/expr/src/expr_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl ExprSchemable for Expr {
9999
/// expression refers to a column that does not exist in the
100100
/// schema, or when the expression is incorrectly typed
101101
/// (e.g. `[utf8] + [bool]`).
102-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
102+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
103103
fn get_type(&self, schema: &dyn ExprSchema) -> Result<DataType> {
104104
match self {
105105
Expr::Alias(Alias { expr, name, .. }) => match &**expr {

datafusion/expr/src/logical_plan/tree_node.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl LogicalPlan {
668668

669669
/// Visits a plan similarly to [`Self::visit`], including subqueries that
670670
/// may appear in expressions such as `IN (SELECT ...)`.
671-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
671+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
672672
pub fn visit_with_subqueries<V: for<'n> TreeNodeVisitor<'n, Node = Self>>(
673673
&self,
674674
visitor: &mut V,
@@ -687,7 +687,7 @@ impl LogicalPlan {
687687
/// Similarly to [`Self::rewrite`], rewrites this node and its inputs using `f`,
688688
/// including subqueries that may appear in expressions such as `IN (SELECT
689689
/// ...)`.
690-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
690+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
691691
pub fn rewrite_with_subqueries<R: TreeNodeRewriter<Node = Self>>(
692692
self,
693693
rewriter: &mut R,
@@ -706,7 +706,7 @@ impl LogicalPlan {
706706
&self,
707707
mut f: F,
708708
) -> Result<TreeNodeRecursion> {
709-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
709+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
710710
fn apply_with_subqueries_impl<
711711
F: FnMut(&LogicalPlan) -> Result<TreeNodeRecursion>,
712712
>(
@@ -741,7 +741,7 @@ impl LogicalPlan {
741741
self,
742742
mut f: F,
743743
) -> Result<Transformed<Self>> {
744-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
744+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
745745
fn transform_down_with_subqueries_impl<
746746
F: FnMut(LogicalPlan) -> Result<Transformed<LogicalPlan>>,
747747
>(
@@ -766,7 +766,7 @@ impl LogicalPlan {
766766
self,
767767
mut f: F,
768768
) -> Result<Transformed<Self>> {
769-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
769+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
770770
fn transform_up_with_subqueries_impl<
771771
F: FnMut(LogicalPlan) -> Result<Transformed<LogicalPlan>>,
772772
>(
@@ -794,7 +794,7 @@ impl LogicalPlan {
794794
mut f_down: FD,
795795
mut f_up: FU,
796796
) -> Result<Transformed<Self>> {
797-
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
797+
#[cfg_attr(feature = "recursive_protection", recursive::recursive)]
798798
fn transform_down_up_with_subqueries_impl<
799799
FD: FnMut(LogicalPlan) -> Result<Transformed<LogicalPlan>>,
800800
FU: FnMut(LogicalPlan) -> Result<Transformed<LogicalPlan>>,

datafusion/optimizer/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ name = "datafusion_optimizer"
3636
path = "src/lib.rs"
3737

3838
[features]
39-
default = ["recursive-protection"]
40-
recursive-protection = ["dep:recursive"]
39+
recursive_protection = ["dep:recursive"]
4140

4241
[dependencies]
4342
arrow = { workspace = true }

0 commit comments

Comments
 (0)