You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@auron.apache.org by "ShreyeshArangath (via GitHub)" <gi...@apache.org> on 2026/01/25 04:41:36 UTC
[PR] [AURON #1889]Implement monotonically_increasing_id() function [auron]
ShreyeshArangath opened a new pull request, #1955:
URL: https://github.com/apache/auron/pull/1955
<!--
- Start the PR title with the related issue ID, e.g. '[AURON #XXXX] Short summary...'.
-->
# Which issue does this PR close?
Closes #1889
# Rationale for this change
Adds's support for non-deterministic function, as part of #1833
# What changes are included in this PR?
Implements native support for Spark's `monotonically_increasing_id()`` function in Auron.
Functionality TL;DR:
The `monotonically_increasing_id()` function generates unique, monotonically increasing 64-bit integers across all partitions. Each partition generates IDs using the formula:
```go
id := (partition_id << 33) | row_number
```
- Each ID is globally unique across all partitions
- IDs increase monotonically within each partition
- The upper 31 bits encode the partition ID, while the lower 33 bits encode the row number within that partition
# Are there any user-facing changes?
N/A
# How was this patch tested?
Unit tests
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON #1889] Implement monotonically_increasing_id() function [auron]
Posted by "ShreyeshArangath (via GitHub)" <gi...@apache.org>.
ShreyeshArangath commented on PR #1955:
URL: https://github.com/apache/auron/pull/1955#issuecomment-3837935496
Are we good to merge this in? @richox / @cxzl25
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON #1889] Implement monotonically_increasing_id() function [auron]
Posted by "richox (via GitHub)" <gi...@apache.org>.
richox merged PR #1955:
URL: https://github.com/apache/auron/pull/1955
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON #1889] Implement monotonically_increasing_id() function [auron]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1955:
URL: https://github.com/apache/auron/pull/1955#discussion_r2726241476
##########
native-engine/datafusion-ext-exprs/src/spark_monotonically_increasing_id.rs:
##########
@@ -0,0 +1,245 @@
+// 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.
+
+use std::{
+ any::Any,
+ fmt::{Debug, Display, Formatter},
+ hash::{Hash, Hasher},
+ sync::{
+ Arc,
+ atomic::{AtomicI64, Ordering::SeqCst},
+ },
+};
+
+use arrow::{
+ array::{Int64Array, RecordBatch},
+ datatypes::{DataType, Schema},
+};
+use datafusion::{
+ common::Result,
+ logical_expr::ColumnarValue,
+ physical_expr::{PhysicalExpr, PhysicalExprRef},
+};
+
+pub struct SparkMonotonicallyIncreasingIdExpr {
+ partition_id: i64,
+ row_counter: AtomicI64,
+}
+
+impl SparkMonotonicallyIncreasingIdExpr {
+ pub fn new(partition_id: usize) -> Self {
+ Self {
+ partition_id: partition_id as i64,
+ row_counter: AtomicI64::new(0),
+ }
+ }
+}
+
+impl Display for SparkMonotonicallyIncreasingIdExpr {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(f, "MonotonicallyIncreasingID")
+ }
+}
+
+impl Debug for SparkMonotonicallyIncreasingIdExpr {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(f, "MonotonicallyIncreasingID")
+ }
+}
+
+impl PartialEq for SparkMonotonicallyIncreasingIdExpr {
+ fn eq(&self, other: &Self) -> bool {
+ self.partition_id == other.partition_id
+ && self.row_counter.load(SeqCst) == other.row_counter.load(SeqCst)
+ }
+}
+
+impl Eq for SparkMonotonicallyIncreasingIdExpr {}
+
+impl Hash for SparkMonotonicallyIncreasingIdExpr {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.partition_id.hash(state);
+ self.row_counter.load(SeqCst).hash(state);
+ }
Review Comment:
`PartialEq` and `Hash` currently incorporate `row_counter`, so the equality and hash of `SparkMonotonicallyIncreasingIdExpr` change as the expression is evaluated. For non-deterministic physical expressions we generally avoid depending on mutable internal state in Eq/Hash (see `row_num.rs:53-64`), to keep expression identity stable for caching/reuse and map/set keys. Consider basing Eq/Hash only on the static configuration (e.g., `partition_id`) or mirroring `RowNumExpr` by making all instances equal with a constant hash.
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON #1889] Implement monotonically_increasing_id() function [auron]
Posted by "ShreyeshArangath (via GitHub)" <gi...@apache.org>.
ShreyeshArangath commented on PR #1955:
URL: https://github.com/apache/auron/pull/1955#issuecomment-3812767255
@cxzl25 can I get a re-review on this? Thanks!
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org