Incremental GROUP BY _block_num and DISTINCT BY _block_num#1877
Open
Incremental GROUP BY _block_num and DISTINCT BY _block_num#1877
GROUP BY _block_num and DISTINCT BY _block_num#1877Conversation
Signed-off-by: Leonardo Yvens <leoyvens@gmail.com>
Allow GROUP BY queries that include _block_num as a group key to work with incremental processing instead of being rejected. - Handle Aggregate in BlockNumPropagator by setting next_block_num_expr - Remove Aggregate from the unsupported-node error arm Signed-off-by: Leonardo Yvens <leoyvens@gmail.com>
LNSD
reviewed
Feb 27, 2026
Contributor
LNSD
left a comment
There was a problem hiding this comment.
Please, check my comments 🙂
crates/core/common/src/lib.rs
Outdated
| pub use datafusion::{arrow, parquet}; | ||
| pub use datasets_common::{block_num::BlockNum, block_range::BlockRange, end_block::EndBlock}; | ||
|
|
||
| pub mod block_num_udf; |
Contributor
There was a problem hiding this comment.
Can we rename the module to just block_num? maybe we can move all the UDFs under common::udfs (e.g., common::udfs::evm::* or common::udfs::block_num)
Signed-off-by: Leo <leo@edgeandnode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements two related features:
DISTINCT ONandGROUP BY, when the key is_block_numblock_num()to more easily refer to the block number anywhere in the query.Our execution semantics essentially already support the special case where an aggregation is restricted to within a block, thanks to the assumption that data for a same block never spans more than a single microbatch. So executing the aggregation in isolation on each microbatch yields correct results. The necessary changes were around incremental query validation checks and block number propagation.