Skip to content

Commit 37a3812

Browse files
committed
Allow ARRAY keyword to be used as identifier (column name)
When ARRAY is not followed by '(', treat it as an identifier rather than requiring it to be a constructor. This allows column names like 'array' to be referenced correctly.
1 parent 8309f9e commit 37a3812

13 files changed

Lines changed: 16 additions & 112 deletions

File tree

parser/expression.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,12 @@ func (p *Parser) parsePrefixExpression() ast.Expression {
303303
case token.COLUMNS:
304304
return p.parseColumnsMatcher()
305305
case token.ARRAY:
306-
// array(1,2,3) constructor
307-
return p.parseArrayConstructor()
306+
// array(1,2,3) constructor or array as identifier (column name)
307+
if p.peekIs(token.LPAREN) {
308+
return p.parseArrayConstructor()
309+
}
310+
// array used as identifier (column/variable name)
311+
return p.parseKeywordAsIdentifier()
308312
case token.IF:
309313
// IF function
310314
return p.parseIfFunction()
Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt17": true,
4-
"stmt18": true,
5-
"stmt20": true,
6-
"stmt21": true,
7-
"stmt22": true,
8-
"stmt23": true,
9-
"stmt24": true,
10-
"stmt25": true,
11-
"stmt26": true,
12-
"stmt28": true,
13-
"stmt29": true,
14-
"stmt3": true,
15-
"stmt30": true,
16-
"stmt31": true,
17-
"stmt32": true,
18-
"stmt33": true,
19-
"stmt34": true,
20-
"stmt36": true,
21-
"stmt37": true,
22-
"stmt38": true,
23-
"stmt39": true,
24-
"stmt40": true,
25-
"stmt41": true,
26-
"stmt42": true,
27-
"stmt44": true,
28-
"stmt45": true,
29-
"stmt46": true,
30-
"stmt47": true,
31-
"stmt48": true,
32-
"stmt49": true,
33-
"stmt50": true,
34-
"stmt52": true,
35-
"stmt53": true,
36-
"stmt54": true,
37-
"stmt55": true,
38-
"stmt56": true,
39-
"stmt57": true,
40-
"stmt58": true,
41-
"stmt60": true,
42-
"stmt61": true,
43-
"stmt62": true,
44-
"stmt63": true,
45-
"stmt64": true,
46-
"stmt65": true,
47-
"stmt66": true,
48-
"stmt68": true,
49-
"stmt70": true,
50-
"stmt72": true,
51-
"stmt74": true,
52-
"stmt76": true,
53-
"stmt78": true,
54-
"stmt80": true,
55-
"stmt81": true
56-
}
57-
}
1+
{}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"explain_todo": {
33
"stmt10": true,
4-
"stmt12": true,
5-
"stmt5": true,
6-
"stmt7": true,
7-
"stmt9": true
4+
"stmt12": true
85
}
96
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt25": true
4-
}
5-
}
1+
{}
Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt13": true,
4-
"stmt14": true,
5-
"stmt15": true,
6-
"stmt3": true,
7-
"stmt4": true,
8-
"stmt7": true,
9-
"stmt8": true,
10-
"stmt9": true
11-
}
12-
}
1+
{}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"explain_todo": {
33
"stmt102": true,
4-
"stmt103": true,
5-
"stmt29": true
4+
"stmt103": true
65
}
76
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"explain_todo": {
3-
"stmt12": true,
4-
"stmt9": true
3+
"stmt12": true
54
}
65
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"explain_todo": {
33
"stmt11": true,
4-
"stmt13": true,
5-
"stmt9": true
4+
"stmt13": true
65
}
76
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"explain_todo": {
3-
"stmt14": true,
4-
"stmt9": true
3+
"stmt14": true
54
}
65
}
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt11": true,
4-
"stmt13": true,
5-
"stmt15": true,
6-
"stmt17": true,
7-
"stmt19": true,
8-
"stmt21": true,
9-
"stmt23": true,
10-
"stmt25": true,
11-
"stmt27": true,
12-
"stmt29": true,
13-
"stmt3": true,
14-
"stmt31": true,
15-
"stmt33": true,
16-
"stmt4": true,
17-
"stmt7": true,
18-
"stmt9": true
19-
}
20-
}
1+
{}

0 commit comments

Comments
 (0)