18740: fix: update schema's data type for LogicalPlan::Values after placeholder substitution - #29
martin-augment wants to merge 2 commits into
Conversation
WalkthroughThe pull request modifies the schema update path in the logical planner by replacing a ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
datafusion/expr/src/logical_plan/plan.rs (2)
1480-1482: Consider enhancing the documentation.The comment could be more explicit about what this method does differently from
recompute_schema(). For example:/// Recomputes schema fields' data type after replacing params, ensuring fields data type can be /// updated according to the new parameters. Unlike `recompute_schema()`, this method rebuilds /// VALUES plans entirely to properly infer types from literal values after placeholder substitution.
1484-1488: Consider tracking the FIXME as technical debt.The FIXME comment indicates that special-casing VALUES is a workaround. The root cause is that
recompute_schema()doesn't handle VALUES plans (see lines 635-638). Consider:
- Creating an issue to track fixing
recompute_schema()to properly handle VALUES plans- Linking the FIXME comment to that issue
- Evaluating whether the inconsistency between VALUES and other plan types could cause issues in the future
Additionally, when rebuilding the VALUES plan via
LogicalPlanBuilder::values(values)?.build(), any schema-level metadata from the originalValues.schemais discarded sincevalues()callsinfer_data()which creates a fresh schema. If schema metadata preservation is important for VALUES plans in prepared statements, this should be addressed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
datafusion/expr/src/logical_plan/plan.rs(1 hunks)datafusion/sqllogictest/test_files/prepare.slt(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
datafusion/expr/src/logical_plan/plan.rs (1)
datafusion/expr/src/logical_plan/builder.rs (2)
plan(160-162)values(215-236)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: claude-review
- GitHub Check: Analyze (rust)
🔇 Additional comments (1)
datafusion/sqllogictest/test_files/prepare.slt (1)
366-375: LGTM! Good test coverage for untyped VALUES with parameters.This test case validates the schema update logic when placeholders in a VALUES clause are replaced with concrete values, without explicit type declarations in the PREPARE statement. This complements the existing test at line 102 which uses explicit type declarations.
Pull Request Review: Fix schema data type update for LogicalPlan::Values after placeholder substitutionSummaryThis PR addresses issue apache#18740 by ensuring that the schema's data types are properly updated for Code Quality and Best PracticesPositive aspects:
Recommendations:
Potential Bugs or IssuesMinor concern:
Validation:
Performance ConsiderationsMinor overhead:
Optimization opportunity (future):
Security ConcernsNo security issues identified. The change:
Test CoverageGood:
Recommendations:
Overall AssessmentVerdict: Approve with minor suggestions This is a solid fix for the reported issue. The implementation is straightforward and correct, though it's clearly a workaround for a deeper issue in Recommendations summary:
Great work on identifying and fixing this issue! |
value:useful; good-to-have:documentation; feedback:The Claude AI reviewer is correct. The "FIXME" suggests that the newly introduced code is broken and needs to be fixed. It would be better to note instead that this is a temporary hack/workaround that needs to be improved later by filling an issue. Prevents confusion in the next developer who reads this code comment. |
value:useful; good-to-have:documentation; feedback:The CodeRabbit AI reviewer is correct. The "FIXME" suggests that the newly introduced code is broken and needs to be fixed. It would be better to note instead that this is a temporary hack/workaround that needs to be improved later by filling an issue. Prevents confusion in the next developer who reads this code comment. |
value:good-to-have; category:documentation; feedback: The Claude AI reviewer is correct that the method documentation could be improved to explain why the new method is needed. It is obvious from the method body implementation what it does but not why it does it. |
value:good-to-have; category:documentation; feedback: The CodeRabbit AI reviewer is correct that the method documentation could be improved to explain why the new method is needed. It is obvious from the method body implementation what it does but not why it does it. |
18740: To review by AI