Skip to content

Conversation

@jycor
Copy link
Contributor

@jycor jycor commented May 15, 2025

Using aggregation and window functions inside a select statement inside an insert source inside a trigger was causing problems. For example, a trigger defined like so:

create trigger trig before insert on t1
for each row
begin
  insert into t2
  select 
     max(id),
     first_value(id) over (partition by id order by id),
     ...
  from
     t3;
end;

The issue involved the Projections over the Group Bys. The scope for the group bys already contained the trigger's columns and are indexed uniquely, so we shouldn't include the trigger/parent scope.

@jycor jycor changed the title first pass at fix fix indexing for GROUP BYs and WINDOWs in INSERT and REPLACE statements in TRIGGERS May 15, 2025
Copy link
Contributor

@fulghum fulghum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jycor jycor merged commit 5d12b6a into main May 16, 2025
8 checks passed
@jycor jycor deleted the james/window branch May 16, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants