You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2026/08/14 16:52:22 UTC
[PR] feat: support floating-point ASOF equality keys [datafusion]
Xuanwo opened a new pull request, #24375:
URL: https://github.com/apache/datafusion/pull/24375
## Which issue does this PR close?
- Part of #318.
- Umbrella PR: #23738.
- Depends on #23828.
## Rationale for this change
The physical ASOF operator in #23828 rejects floating-point equality keys because
Arrow's total ordering distinguishes `-0.0` from `+0.0`, while join equality
treats them as equal. That mismatch can split one equality group during the
required input sort and make the forward-only ASOF scan choose the wrong row.
This follow-up keeps the independently mergeable physical operator conservative,
then adds complete Float16, Float32, and Float64 equality-key support as a
separate stack layer.
GitHub shows the cumulative stack because fork branches cannot be selected as
upstream PR bases. The isolated diff for this layer is:
https://github.com/Xuanwo/datafusion/compare/xuanwo/asof-physical...xuanwo/asof-float-equality
## What changes are included in this PR?
- Add an order-preserving `NormalizeFloatZeroExpr` that maps `-0.0` to
`+0.0` without changing other values.
- Use the expression only for floating-point ASOF equality-key ordering, so the
required sort order agrees with the existing join-key comparator.
- Add protobuf encode/decode support so plans containing the required sort
expression round-trip correctly.
- Add a regression covering Float16, Float32, and Float64 where
`(-0.0, ts=10)` followed by `(+0.0, ts=1)` must remain one group and select
`ts=1` for a left `(+0.0, ts=5)` row.
## Are these changes tested?
Yes:
- `cargo fmt --all`
- `cargo clippy --all-targets --all-features -- -D warnings`
- ASOF physical operator tests, including all three floating-point types
- Logical and physical protobuf round-trip tests
- Extended workspace tests from the contributor guide
- FFI integration tests
## Are there any user-facing changes?
ASOF equality keys can use Float16, Float32, and Float64 while treating signed
zero consistently with join equality. This layer also adds a public physical
expression and an append-only protobuf oneof variant; existing wire tags are not
reused.
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3871572331
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
I'll take a look at this. My read is that it's handling the edge cases for asof join. Would it make sense to land a minimal PR first — just enough to get a simple asof join working — and then iterate on the other cases after that? What do you think?
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3878051917
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
Yep, only ASOF join use this part of logic. I'm open to leave it as a follow-up. I'll adjust the stack and get it a out so that we can work on ASOF join first.
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#issuecomment-5296146207
## [Codecov](https://app.codecov.io/gh/apache/datafusion/pull/24375?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 `75.35411%` with `348 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 81.17%. Comparing base ([`ec110ce`](https://app.codecov.io/gh/apache/datafusion/commit/ec110cea1875972f2593cdade2f901bfd47c4157?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`e570325`](https://app.codecov.io/gh/apache/datafusion/commit/e5703257251baccd32782ae658a51c993f4e4954?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/24375?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-plan/src/joins/asof\_join.rs](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&filepath=datafusion%2Fphysical-plan%2Fsrc%2Fjoins%2Fasof_join.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1wbGFuL3NyYy9qb2lucy9hc29mX2pvaW4ucnM=) | 79.71% | [191 Missing and 65 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [datafusion/proto-models/src/generated/pbjson.rs](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&filepath=datafusion%2Fproto-models%2Fsrc%2Fgenerated%2Fpbjson.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9wcm90by1tb2RlbHMvc3JjL2dlbmVyYXRlZC9wYmpzb24ucnM=) | 0.00% | [57 Missing :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...sical-expr/src/expressions/normalize\_float\_zero.rs](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&filepath=datafusion%2Fphysical-expr%2Fsrc%2Fexpressions%2Fnormalize_float_zero.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9waHlzaWNhbC1leHByL3NyYy9leHByZXNzaW9ucy9ub3JtYWxpemVfZmxvYXRfemVyby5ycw==) | 63.04% | [29 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [datafusion/proto/src/physical\_plan/from\_proto.rs](https://app.codecov.io/gh/apache/datafusion/pull/24375?src=pr&el=tree&filepath=datafusion%2Fproto%2Fsrc%2Fphysical_plan%2Ffrom_proto.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZGF0YWZ1c2lvbi9wcm90by9zcmMvcGh5c2ljYWxfcGxhbi9mcm9tX3Byb3RvLnJz) | 0.00% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/datafusion/pull/24375?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 #24375 +/- ##
==========================================
- Coverage 81.19% 81.17% -0.02%
==========================================
Files 1110 1112 +2
Lines 388618 390030 +1412
Branches 388618 390030 +1412
==========================================
+ Hits 315531 316601 +1070
- Misses 54507 54773 +266
- Partials 18580 18656 +76
```
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/datafusion/pull/24375?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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "github-actions[bot] (via GitHub) via github" <gi...@datafusion.apache.org>.
github-actions[bot] commented on PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#issuecomment-6755949126
Marked as draft after 14 days without activity: merge conflicts.
Please address these items and mark **Ready for review** when ready.
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#issuecomment-5392500298
cc @2010YOUY01, this PR is now ready for review!
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3871572331
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
Let me take a look for this, btw, I guess this is dealing with the "edge" case for asof join, maybe we could move on other minimum requirement PR to have the first simple asoj join work, after that we can iterate on it for more cases, what do you think?
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#issuecomment-5295974927
<!-- semver-check-comment -->
Thank you for opening this pull request!
Reviewer note: [cargo-semver-checks](https://github.com/obi1kenobi/cargo-semver-checks) reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).
<details>
<summary>Details</summary>
```
Cloning apache/main
Building datafusion-physical-expr v54.1.0 (current)
Built [ 30.778s] (current)
Parsing datafusion-physical-expr v54.1.0 (current)
Parsed [ 0.055s] (current)
Building datafusion-physical-expr v54.1.0 (baseline)
Built [ 29.122s] (baseline)
Parsing datafusion-physical-expr v54.1.0 (baseline)
Parsed [ 0.054s] (baseline)
Checking datafusion-physical-expr v54.1.0 -> v54.1.0 (no change; assume patch)
Checked [ 0.529s] 223 checks: 223 pass, 31 skip
Summary no semver update required
Finished [ 61.903s] datafusion-physical-expr
Building datafusion-physical-plan v54.1.0 (current)
Built [ 37.535s] (current)
Parsing datafusion-physical-plan v54.1.0 (current)
Parsed [ 0.157s] (current)
Building datafusion-physical-plan v54.1.0 (baseline)
Built [ 37.410s] (baseline)
Parsing datafusion-physical-plan v54.1.0 (baseline)
Parsed [ 0.154s] (baseline)
Checking datafusion-physical-plan v54.1.0 -> v54.1.0 (no change; assume patch)
Checked [ 1.000s] 223 checks: 223 pass, 31 skip
Summary no semver update required
Finished [ 77.629s] datafusion-physical-plan
Building datafusion-proto v54.1.0 (current)
Built [ 53.185s] (current)
Parsing datafusion-proto v54.1.0 (current)
Parsed [ 0.019s] (current)
Building datafusion-proto v54.1.0 (baseline)
Built [ 53.612s] (baseline)
Parsing datafusion-proto v54.1.0 (baseline)
Parsed [ 0.020s] (baseline)
Checking datafusion-proto v54.1.0 -> v54.1.0 (no change; assume patch)
Checked [ 0.167s] 223 checks: 223 pass, 31 skip
Summary no semver update required
Finished [ 108.576s] datafusion-proto
Building datafusion-proto-models v54.1.0 (current)
Built [ 24.895s] (current)
Parsing datafusion-proto-models v54.1.0 (current)
Parsed [ 0.138s] (current)
Building datafusion-proto-models v54.1.0 (baseline)
Built [ 24.850s] (baseline)
Parsing datafusion-proto-models v54.1.0 (baseline)
Parsed [ 0.137s] (baseline)
Checking datafusion-proto-models v54.1.0 -> v54.1.0 (no change; assume patch)
Checked [ 2.557s] 223 checks: 222 pass, 1 fail, 0 warn, 31 skip
--- failure enum_variant_added: enum variant added on exhaustive enum ---
Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.50.0/src/lints/enum_variant_added.ron
Failed in:
variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1626
variant ExprType:NormalizeFloatZero in /home/runner/work/datafusion/datafusion/datafusion/proto-models/src/generated/prost.rs:1626
Summary semver requires new major version: 1 major and 0 minor checks failed
Finished [ 54.238s] datafusion-proto-models
```
</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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3862621352
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
I still have a question about why we introduce another PhysicalExpr to handle this type issue instead of just calling normalize_float_zero.
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "jayzhan211 (via GitHub)" <gi...@apache.org>.
jayzhan211 commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3871572331
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
I'll take a look at this. My read is that it's handling the edge cases for asof join.
One thing I'm worried about: we'd end up with `NormalizeFloatZeroExpr` and `normalize_float_zero` spread across a lot of call sites, which seems likely to cause confusion down the line.
Would it make sense to land a minimal PR first — just enough to get a simple asof join working — and then iterate on the other cases after that? What do you think?
--
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] feat: support floating-point ASOF equality keys [datafusion]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #24375:
URL: https://github.com/apache/datafusion/pull/24375#discussion_r3864267097
##########
datafusion/physical-expr/src/expressions/normalize_float_zero.rs:
##########
@@ -0,0 +1,255 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Floating-point signed-zero normalization expression.
+
+use std::hash::Hash;
+use std::sync::Arc;
+
+use arrow::datatypes::{DataType, FieldRef, Schema};
+use arrow::record_batch::RecordBatch;
+use datafusion_common::Result;
+use datafusion_common::utils::{normalize_float_zero, normalize_float_zero_scalar};
+use datafusion_expr::ColumnarValue;
+use datafusion_expr::interval_arithmetic::Interval;
+use datafusion_expr::sort_properties::ExprProperties;
+
+use crate::PhysicalExpr;
+
+/// Replaces floating-point `-0.0` values with `+0.0`.
+///
+/// Other values and data types are returned unchanged. This expression is
+/// order-preserving but not strictly order-preserving because it collapses the
+/// two signed-zero representations.
+#[derive(Debug, Eq)]
+pub struct NormalizeFloatZeroExpr {
Review Comment:
Good question. `normalize_float_zero` works on an already evaluated array, but here normalization must be part of the required ordering.
For example, raw `[key, ts]` may be `(-0, 10), (+0, 1)`. Normalizing only during comparison makes them one equality group but leaves `ts` as `[10, 1]`, breaking the forward scan. We need the input sorted by `[normalize_float_zero(key), ts]`.
The new `PhysicalExpr` is the plan-level wrapper around the existing helper, allowing `SortExec`, ordering enforcement, and protobuf to represent this without changing float sorting globally.
---
Let me know if this addressed your concerns. I'm open to better ideas!
--
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