Skip to content

Commit

Permalink
Fix error when union all duplicates columns
Browse files Browse the repository at this point in the history
  • Loading branch information
mput committed Mar 25, 2024
1 parent 361fbf1 commit 74ce11b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 14 additions & 3 deletions sof-js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,20 @@ function collect_columns(acc, def){
return collect_columns(acc, s);
}, acc)
case 'unionAll':
return def.unionAll.reduce((acc, s)=> {
return collect_columns(acc, s);
}, acc)
let unions = def.unionAll.map((s)=> {
return collect_columns([], s);
})

if (unions.length > 1) {
let first = unions[0];
for (let i = 1; i < unions.length; ++i) {
if (!arrays_eq(first, unions[i])) {
throw new Error(`Union columns mismatch: ${JSON.stringify(unions)}`);
}
}
}

return acc.concat(unions[0])
case 'column':
return def.column.reduce((acc, c)=> {
acc.push(c.name || c.path)
Expand Down
1 change: 1 addition & 0 deletions sof-js/src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function viewdef_schema(for_tests = false) {
properties: {
title: string,
status: string,
description: string,
resourceType: string,
name: string,
resource: identifier,
Expand Down

0 comments on commit 74ce11b

Please sign in to comment.