You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Jefffrey (via GitHub)" <gi...@apache.org> on 2026/08/06 10:44:11 UTC
[PR] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Jefffrey opened a new pull request, #24140:
URL: https://github.com/apache/datafusion/pull/24140
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- From https://github.com/apache/datafusion/issues/15914#issuecomment-4324008673
- Relates to https://github.com/apache/datafusion/issues/21959
- Relates to https://github.com/apache/datafusion/discussions/22012
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
Please explain the problem you are trying to solve in terms of the user-visible
behavior, rather than the implementation.
For example, "The code in `foo.rs` doesn't handle nulls" is a symptom of the
implementation. "COUNT(DISTINCT) returns wrong results when the column contains
nulls" is the user-visible problem.
-->
Set some guidelines for how UDFs should be implemented in `datafusion-spark`. This is to align us on what we expect from UDFs, making it easier for contributors & reviewers alike.
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#discussion_r3735036871
##########
datafusion/spark/README.md:
##########
@@ -27,23 +27,39 @@ This crate is a submodule of DataFusion that provides [Apache Spark] compatible
[apache datafusion]: https://datafusion.apache.org/
[apache spark]: https://spark.apache.org/
-## Testing Guide
+## Implementation Guidelines
-When testing functions by directly invoking them (e.g., `test_scalar_function!()`), input coercion (from the `signature`
-or `coerce_types`) is not applied.
+When implementing these functions, you can check if there are existing implementations
+in the [Sail] or [Comet] projects first. If you do port functionality from these
+sources, make sure to port over the corresponding tests too, to ensure correctness
+and compatibility.
-Therefore, direct invocation tests should only be used to verify that the function is correctly implemented.
+### `simplify()`
Review Comment:
This is one of the cases where Rust unit tests would be needed; though perhaps it also suggests that maybe we should stick to `invoke_with_args` only, and avoid `simplify` altogether especially in cases where it is an unconditional rewrite 🤔
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#discussion_r3729844758
##########
datafusion/spark/README.md:
##########
@@ -27,23 +27,39 @@ This crate is a submodule of DataFusion that provides [Apache Spark] compatible
[apache datafusion]: https://datafusion.apache.org/
[apache spark]: https://spark.apache.org/
-## Testing Guide
+## Implementation Guidelines
-When testing functions by directly invoking them (e.g., `test_scalar_function!()`), input coercion (from the `signature`
-or `coerce_types`) is not applied.
+When implementing these functions, you can check if there are existing implementations
+in the [Sail] or [Comet] projects first. If you do port functionality from these
+sources, make sure to port over the corresponding tests too, to ensure correctness
+and compatibility.
-Therefore, direct invocation tests should only be used to verify that the function is correctly implemented.
+### `simplify()`
Review Comment:
There is a challenge here on how to write sql logic tests to test both the `simplify` and the `invoke_with_args` implementations.
Do you have suggestions on how to address this?
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#discussion_r3739647227
##########
datafusion/spark/README.md:
##########
@@ -27,23 +27,39 @@ This crate is a submodule of DataFusion that provides [Apache Spark] compatible
[apache datafusion]: https://datafusion.apache.org/
[apache spark]: https://spark.apache.org/
-## Testing Guide
+## Implementation Guidelines
-When testing functions by directly invoking them (e.g., `test_scalar_function!()`), input coercion (from the `signature`
-or `coerce_types`) is not applied.
+When implementing these functions, you can check if there are existing implementations
+in the [Sail] or [Comet] projects first. If you do port functionality from these
+sources, make sure to port over the corresponding tests too, to ensure correctness
+and compatibility.
-Therefore, direct invocation tests should only be used to verify that the function is correctly implemented.
+### `simplify()`
Review Comment:
This sounds great, especially for the datafusion UDFs; itll be easier to have tests in slts that can run with & without simplify to ensure they have same result, instead of having those tests split between slt and rust unit test
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#discussion_r3736679166
##########
datafusion/spark/README.md:
##########
@@ -27,23 +27,39 @@ This crate is a submodule of DataFusion that provides [Apache Spark] compatible
[apache datafusion]: https://datafusion.apache.org/
[apache spark]: https://spark.apache.org/
-## Testing Guide
+## Implementation Guidelines
-When testing functions by directly invoking them (e.g., `test_scalar_function!()`), input coercion (from the `signature`
-or `coerce_types`) is not applied.
+When implementing these functions, you can check if there are existing implementations
+in the [Sail] or [Comet] projects first. If you do port functionality from these
+sources, make sure to port over the corresponding tests too, to ensure correctness
+and compatibility.
-Therefore, direct invocation tests should only be used to verify that the function is correctly implemented.
+### `simplify()`
Review Comment:
Ideally we need to guarantee parity between `simplify` and `invoke_with_args` however there is no flag the spark function is simplified to make a decision.
We prob need to come up with solution to disable optimizer rules in slt.
Spark already has this through `SQLConf.OPTIMIZER_EXCLUDED_RULES` I suppose we need similar for DataFusion, not only for Spark but in general.
Having the mechanism it would be easier to solve questions like @andygrove mentioned. If you okay, I can come up with draft PR
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#issuecomment-5349820135
Shall we merge this one?
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead merged PR #24140:
URL: https://github.com/apache/datafusion/pull/24140
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#issuecomment-5203871592
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/24140?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.04%. Comparing base ([`70c26a0`](https://app.codecov.io/gh/apache/datafusion/commit/70c26a06716eb552f0fc1d2115957a4089504f11?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`fe20858`](https://app.codecov.io/gh/apache/datafusion/commit/fe2085828a8e1a6e8912a6bcc0cf7b6b12e0565e?dropdown=coverage&el=desc&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 #24140 +/- ##
==========================================
- Coverage 81.04% 81.04% -0.01%
==========================================
Files 1105 1105
Lines 380163 380163
Branches 380163 380163
==========================================
- Hits 308111 308107 -4
- Misses 53834 53836 +2
- Partials 18218 18220 +2
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/24140?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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#issuecomment-5203609436
I didn't receive an answer regarding datatypes so I just put a view here; am open to changing it if others have differing opinions.
cc @comphead @andygrove @coderfender
--
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] doc: add implementation guidelines for `datafusion-spark` [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #24140:
URL: https://github.com/apache/datafusion/pull/24140#issuecomment-5349909598
> Shall we merge this one?
Yes lets go with it, there will be a followup PR to test out `simplify` and `invoke_with_args`
--
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