Skip to content

HAVING clause should not require parentheses when involving AND or OR #111

@rogerlucena

Description

@rogerlucena

When using a HAVING clause, it should not be required for the expressions around AND or OR operators to be surrounded by parentheses.

To illustrate, nowadays the following query in BQL works:

SELECT ?parent_name, ?child_name, ?child_height
FROM ?family
WHERE {
  ?parent ID ?parent_name "parent_of"@[] ?child ID ?child_name .
  ?child "height_cm"@[] ?child_height
}
HAVING (?child_height > "150"^^type:int64) AND (?parent = /u<peter>);

But the following does not:

SELECT ?parent_name, ?child_name, ?child_height
FROM ?family
WHERE {
  ?parent ID ?parent_name "parent_of"@[] ?child ID ?child_name .
  ?child "height_cm"@[] ?child_height
}
HAVING ?child_height > "150"^^type:int64 AND ?parent = /u<peter>;

It yields the following error:

[FAIL] [ERROR] Failed to parse BQL statement with error Parser.parse: Failed to consume symbol HAVING, with error failed to consume all token; left over [{false  0xc00021af50} {false  0xc00021afa0} {false  0xc00021aff0} {false  0xc00021b040}]

This may be related with the NewEvaluator inside expression.go in semantics, as the grammar is not the one restricting this behavior.

You can use the code in the file below to reproduce the aforementioned results.

parentheses_in_having.pdf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions