File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -948,9 +948,10 @@ func (p *Parser) parseInterval() ast.Expression {
948948 }
949949 p .nextToken () // skip INTERVAL
950950
951- expr .Value = p .parseExpression (LOWEST )
951+ // Use ALIAS_PREC to prevent consuming the unit as an alias
952+ expr .Value = p .parseExpression (ALIAS_PREC )
952953
953- // Parse unit
954+ // Parse unit (interval units are identifiers like DAY, MONTH, etc.)
954955 if p .currentIs (token .IDENT ) {
955956 expr .Unit = strings .ToUpper (p .current .Value )
956957 p .nextToken ()
@@ -1298,6 +1299,26 @@ func (p *Parser) parseIsExpression(left ast.Expression) ast.Expression {
12981299 }
12991300 }
13001301
1302+ // IS [NOT] DISTINCT FROM expr
1303+ if p .currentIs (token .DISTINCT ) {
1304+ p .nextToken () // skip DISTINCT
1305+ if p .currentIs (token .FROM ) {
1306+ p .nextToken () // skip FROM
1307+ right := p .parseExpression (COMPARE )
1308+ // IS NOT DISTINCT FROM is same as =, IS DISTINCT FROM is same as !=
1309+ op := "="
1310+ if not {
1311+ op = "!="
1312+ }
1313+ return & ast.BinaryExpr {
1314+ Position : pos ,
1315+ Left : left ,
1316+ Op : op ,
1317+ Right : right ,
1318+ }
1319+ }
1320+ }
1321+
13011322 return left
13021323}
13031324
You can’t perform that action at this time.
0 commit comments