kosiew commented on code in PR #26969:
URL: https://github.com/apache/datafusion/pull/26969#discussion_r4781001907
##########
datafusion/optimizer/src/extract_leaf_expressions.rs:
##########
@@ -71,12 +72,45 @@ use crate::{OptimizerConfig, OptimizerRule};
/// Prefix for aliases generated by the extraction optimizer passes.
///
-/// This prefix is **reserved for internal optimizer use**. User-defined
aliases
-/// starting with this prefix may be misidentified as optimizer-generated
-/// extraction aliases, leading to unexpected behavior. Do not use this prefix
-/// in user queries.
+/// Aliases starting with this prefix are classified as extraction aliases when
+/// their inner expression is eligible for leaf pushdown
+/// ([`ExpressionPlacement::should_push_to_leaves`]). Canonical positive
decimal
+/// suffixes (`1..usize::MAX`, without leading zeros) are parsed solely to seed
+/// [`AliasGenerator`]; user aliases with this prefix that wrap pushable
+/// expressions may still be treated as extraction aliases.
const EXTRACTED_EXPR_PREFIX: &str = "__datafusion_extracted";
+/// Recognizes canonical positive decimal IDs (`1..usize::MAX` without leading
+/// zeros) for seeding [`AliasGenerator`] in
[`advance_generator_past_existing`].
+///
+/// Extraction alias classification uses [`is_extracted_alias`] instead so
+/// generated `usize::MAX` (and wrapped `0`) aliases are accepted while
+/// non-pushable user aliases with canonical names are rejected.
+fn extracted_expr_id(name: &str) -> Option<usize> {
+ let suffix = name
+ .strip_prefix(EXTRACTED_EXPR_PREFIX)?
+ .strip_prefix('_')?;
+ // Integer parsing alone also accepts leading zeros and a leading '+'.
+ if suffix.starts_with('0') || !suffix.bytes().all(|b| b.is_ascii_digit()) {
Review Comment:
Rejecting `_01` or `_+1` during seeding can allocate `_1` despite an
existing scan field, causing previously working SQL to fail with schema
ambiguity. Please restore the previous parsing behavior for IDs below
`usize::MAX` and add the `_01` SQL regression.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]