You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Toby1009 (via GitHub)" <gi...@apache.org> on 2026/10/02 10:35:55 UTC

[PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Toby1009 opened a new pull request, #25967:
URL: https://github.com/apache/datafusion/pull/25967

   ## Which issue does this PR close?
   
   - Closes #25925.
   
   ## Rationale for this change
   
   The time arithmetic SQL tests added in #25668 retain their sorts even when scalar UDF type recovery is removed, because ordinary arithmetic already treats unbounded results as potentially overflowing. Checked arithmetic needs the recovered time type to detect wrapping across midnight, so it provides a regression test for that interaction.
   
   ## What changes are included in this PR?
   
   - Add a checked `date_trunc('hour', t) + INTERVAL '2 hours'` property test over ordered Time64 input. Assert that truncation preserves ordering before checking that time arithmetic drops it.
   - Cover an override returning unbounded Null bounds, and separate bounds-preservation tests from error propagation.
   - Clarify which intervals are replaced or preserved and that direct `PhysicalExpr::evaluate_bounds` calls bypass the fallback.
   
   ## What is the testing strategy for this PR?
   
   The new checked arithmetic test passes with type recovery and fails with `Ordered` instead of `Unordered` when the fallback is removed. Existing SQL tests are retained.
   
   Validation: `cargo clippy --all-targets --all-features -- -D warnings`, `./dev/rust_lint.sh`, the extended workspace test suite, and all 8 scalar-function unit tests. Ablation checks confirm that removing type recovery fails the ordering assertion, and making the truncated child unordered fails the new precondition assertion.
   
   ## Are there any user-facing changes?
   
   UDF bounds documentation is more precise. Execution behavior and public APIs are unchanged.
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 merged PR #25967:
URL: https://github.com/apache/datafusion/pull/25967


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #25967:
URL: https://github.com/apache/datafusion/pull/25967#issuecomment-5950987021

   ## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/25967?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `92.50000%` with `6 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 82.61%. Comparing base ([`f4ca8a8`](https://app.codecov.io/gh/apache/datafusion/commit/f4ca8a87aa8a31f03ab44b33fd701e82a3827be2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`27d5091`](https://app.codecov.io/gh/apache/datafusion/commit/27d5091ca87bd4e1c2f487006a9ef00f63c5a846?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/datafusion/pull/25967?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [datafusion/physical-expr/src/scalar\_function.rs](https://app.codecov.io/gh/apache/datafusion/pull/25967?src=pr&el=tree&filepath=datafusion%2Fphysical-expr%2Fsrc%2Fscalar_function.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9zY2FsYXJfZnVuY3Rpb24ucnM=) | 92.50% | [1 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/25967?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##             main   #25967      +/-   ##
   ==========================================
   - Coverage   82.61%   82.61%   -0.01%     
   ==========================================
     Files        1145     1145              
     Lines      444324   444363      +39     
     Branches   444324   444363      +39     
   ==========================================
   + Hits       367060   367091      +31     
   - Misses      54975    54976       +1     
   - Partials    22289    22296       +7     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/25967?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #25967:
URL: https://github.com/apache/datafusion/pull/25967#discussion_r4166060878


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -527,6 +527,51 @@ mod tests {
         }
     }
 
+    #[test]
+    fn checked_time_arithmetic_uses_recovered_function_type() -> Result<()> {
+        use crate::expressions::BinaryExpr;
+        use arrow::compute::SortOptions;
+        use datafusion_expr::Operator;
+        use datafusion_functions::datetime::date_trunc::DateTruncFunc;
+
+        let time_type = DataType::Time64(TimeUnit::Nanosecond);
+        let precision = Arc::new(Literal::new(ScalarValue::from("hour")));
+        let precision_properties = precision.get_properties(&[])?;
+        let date_trunc = ScalarFunctionExpr::try_new(
+            Arc::new(ScalarUDF::from(DateTruncFunc::new())),
+            vec![precision, Arc::new(Column::new("t", 0))],
+            &Schema::new(vec![Field::new("t", time_type.clone(), true)]),
+            Arc::new(ConfigOptions::default()),
+        )?;
+        let time_properties = ExprProperties::new_unknown()
+            .with_order(SortProperties::Ordered(SortOptions::default()))
+            .with_range(Interval::make_unbounded(&time_type)?);
+        let truncated_properties =
+            date_trunc.get_properties(&[precision_properties, time_properties])?;
+        assert_eq!(

Review Comment:
   This only catches a missing recovery through `BinaryExpr`'s ordering result. If `BinaryExpr` later treats `Null`-typed operands conservatively, the test would pass without recovery. Pin the recovered type directly as well:
   
   ```suggestion
           assert_eq!(
               truncated_properties.range,
               Interval::make_unbounded(&time_type)?
           );
           assert_eq!(
   ```



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Posted by "Toby1009 (via GitHub)" <gi...@apache.org>.
Toby1009 commented on code in PR #25967:
URL: https://github.com/apache/datafusion/pull/25967#discussion_r4169096237


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -527,6 +527,51 @@ mod tests {
         }
     }
 
+    #[test]
+    fn checked_time_arithmetic_uses_recovered_function_type() -> Result<()> {
+        use crate::expressions::BinaryExpr;
+        use arrow::compute::SortOptions;
+        use datafusion_expr::Operator;
+        use datafusion_functions::datetime::date_trunc::DateTruncFunc;
+
+        let time_type = DataType::Time64(TimeUnit::Nanosecond);
+        let precision = Arc::new(Literal::new(ScalarValue::from("hour")));
+        let precision_properties = precision.get_properties(&[])?;
+        let date_trunc = ScalarFunctionExpr::try_new(
+            Arc::new(ScalarUDF::from(DateTruncFunc::new())),
+            vec![precision, Arc::new(Column::new("t", 0))],
+            &Schema::new(vec![Field::new("t", time_type.clone(), true)]),
+            Arc::new(ConfigOptions::default()),
+        )?;
+        let time_properties = ExprProperties::new_unknown()
+            .with_order(SortProperties::Ordered(SortOptions::default()))
+            .with_range(Interval::make_unbounded(&time_type)?);
+        let truncated_properties =
+            date_trunc.get_properties(&[precision_properties, time_properties])?;
+        assert_eq!(

Review Comment:
   Thanks @jayzhan211, great catch! Added the direct range assertion so the test also verifies that the type was recovered.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] test: strengthen scalar UDF type recovery regression coverage [datafusion]

Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on PR #25967:
URL: https://github.com/apache/datafusion/pull/25967#issuecomment-5963803223

   Thanks @Toby1009 


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org