Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

### Fixes

- Don't allow duplicate stream names: #1212
- Fix memory safety issue when using `merge` or `patch` with `state` as target and reassigning the resulting value to `state` [#1217](https://github.com/tremor-rs/tremor-runtime/pull/1217)
- Fix delayed event re-execution in case of errors in a branched pipeline
- Skip instead of fail EQC on out of repo PRs
Expand Down
1 change: 1 addition & 0 deletions tests/query_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ test_cases!(
pp_embed_unrecognized_token4,
pp_embed_unrecognized_token5,
// INSERT
duplicate_stream_name,
window_both_settings,
window_group_by_event_in_target,
window_event_in_target,
Expand Down
3 changes: 3 additions & 0 deletions tests/query_errors/duplicate_stream_name/error.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error:
2 | create stream snot; # this should error
| ^^^^^^^^^^^^^^^^^^ duplicate stream name
5 changes: 5 additions & 0 deletions tests/query_errors/duplicate_stream_name/query.trickle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
create stream snot;
create stream snot; # this should error

select event from in into snot;
select event from snot into out;
13 changes: 12 additions & 1 deletion tremor-script/src/ast/query/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// We want to keep the names here
#![allow(clippy::module_name_repetitions)]

use std::collections::HashSet;

use super::super::raw::{ExprRaw, IdentRaw, ImutExprRaw, ModuleRaw, ScriptRaw, WithExprsRaw};
use super::{
error_generic, error_no_consts, error_no_locals, AggrRegistry, BaseExpr, GroupBy, GroupByInt,
Expand Down Expand Up @@ -55,13 +57,22 @@ impl<'script> QueryRaw<'script> {
mut helper: &mut Helper<'script, 'registry>,
) -> Result<Query<'script>> {
let mut stmts = vec![];
let mut stream_names = HashSet::new();

for (_i, e) in self.stmts.into_iter().enumerate() {
match e {
StmtRaw::ModuleStmt(m) => {
m.define(helper.reg, helper.aggr_reg, &mut vec![], &mut helper)?;
}
other => {
stmts.push(other.up(&mut helper)?);
let f = other.up(&mut helper)?;

if let Stmt::Stream(s) = &f {
if !stream_names.insert(s.id.clone()) {
return error_generic(&f, &f, &"duplicate stream name", &helper.meta);
}
}
stmts.push(f);
}
}
}
Expand Down