Skip to content

Commit

Permalink
Merge pull request #45 from runreveal/ej/project-bugfix
Browse files Browse the repository at this point in the history
Fix project, minor parsing bug.
  • Loading branch information
ejcx authored Mar 5, 2024
2 parents e47deb9 + 7f06c5a commit d5ecd4e
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ func (p *parser) projectOperator(pipe, keyword Token) (*ProjectOperator, error)
return op, makeErrorOpaque(err)
}
sep, ok = p.next()
if !ok || sep.Kind != TokenComma {
if !ok {
return op, nil
}
if sep.Kind != TokenComma {
return op, fmt.Errorf("expected ',' or EOF, got %s", formatToken(p.source, sep))
}
default:
p.prev()
return op, nil
Expand Down
36 changes: 36 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,42 @@ var parserTests = []struct {
},
},
},
{
name: "ProjectError",
query: "StormEvents | project EventId=1 State",
err: true,
want: &TabularExpr{
Source: &TableRef{
Table: &Ident{
Name: "StormEvents",
NameSpan: newSpan(0, 11),
},
},
Operators: []TabularOperator{
&ProjectOperator{
Pipe: newSpan(12, 13),
Keyword: newSpan(14, 21),
Cols: []*ProjectColumn{
{
Name: &Ident{
Name: "EventId",
NameSpan: newSpan(22, 29),
},
Assign: Span{
Start: 29,
End: 30,
},
X: &BasicLit{
Kind: TokenNumber,
Value: "1",
ValueSpan: newSpan(30, 31),
},
},
},
},
},
},
},
{
name: "ProjectExpr",
query: "StormEvents | project TotalInjuries = InjuriesDirect + InjuriesIndirect",
Expand Down

0 comments on commit d5ecd4e

Please sign in to comment.