Repository navigation
Closed
Description
ArcadeDB Version: v22.9.1 (build d082adc/1664822987697/main)
JDK Version: openjdk 11.0.16 2022-07-19
OS: Ubuntu 20.04
I tried to test some properties of comparison operators and ran into a series problems which I could be related. I bundled these three issues as they are likely related.
Expected behavior
truetruetrue
Actual behavior
1.Cannot execute command Encountered " <SELECT> "SELECT "" at line 1, column 1. Was expecting one of: <WHILE> ... <IF> ... <FOREACH> ... ";" ...
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandSQLParsingException: com.arcadedb.query.sql.parser.ParseException: Encountered " <SELECT> "SELECT "" at line 1, column 1.
Was expecting one of:
<WHILE> ...
<IF> ...
<FOREACH> ...
";" ...
at com.arcadedb.query.sql.executor.SQLEngine.parseScript(SQLEngine.java:110)
at com.arcadedb.query.sql.executor.SQLEngine.parseScript(SQLEngine.java:102)
at com.arcadedb.database.EmbeddedDatabase.execute(EmbeddedDatabase.java:1243)
at com.arcadedb.server.ServerDatabase.execute(ServerDatabase.java:415)
at com.arcadedb.server.http.handler.PostCommandHandler.executeScript(PostCommandHandler.java:100)
at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:71)
at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:85)
at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:111)
at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Caused by: com.arcadedb.query.sql.parser.ParseException: Encountered " <SELECT> "SELECT "" at line 1, column 1.
Was expecting one of:
<WHILE> ...
<IF> ...
<FOREACH> ...
";" ...
Cannot execute command Encountered " <SELECT> "SELECT "" at line 1, column 1. Was expecting one of: <WHILE> ... <IF> ... <FOREACH> ... ";" ...
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandSQLParsingException: com.arcadedb.query.sql.parser.ParseException: Encountered " <SELECT> "SELECT "" at line 1, column 1.
Was expecting one of:
<WHILE> ...
<IF> ...
<FOREACH> ...
";" ...
at com.arcadedb.query.sql.executor.SQLEngine.parseScript(SQLEngine.java:110)
at com.arcadedb.query.sql.executor.SQLEngine.parseScript(SQLEngine.java:102)
at com.arcadedb.database.EmbeddedDatabase.execute(EmbeddedDatabase.java:1243)
at com.arcadedb.server.ServerDatabase.execute(ServerDatabase.java:415)
at com.arcadedb.server.http.handler.PostCommandHandler.executeScript(PostCommandHandler.java:100)
at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:71)
at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:85)
at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:111)
at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256)
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Caused by: com.arcadedb.query.sql.parser.ParseException: Encountered " <SELECT> "SELECT "" at line 1, column 1.
Was expecting one of:
<WHILE> ...
<IF> ...
<FOREACH> ...
";" ...
Cannot execute command Unknown function name :evalsee Unknown functioneval()#563
Trace
<ArcadeDB_0> Error on command execution (PostCommandHandler)
com.arcadedb.exception.CommandExecutionException: Unknown function name :eval
Steps to reproduce
SELECT 1 = 1;SELECT if(1 = 1, true, false);SELECT if(eval('1 = 1'), true, false);
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentation
Activity
lvca commentedon Oct 13, 2022
Removed
eval()from the docs following #563gramian commentedon Oct 13, 2022
@lvca Please reopen. Comparisons in projections still don't work, particularly if
eval()is removed.gramian commentedon Oct 13, 2022
@lvca There is one thing I should probably add to this issue:
The whole reason I started testing comparisons in projections, was that I wanted to probe the result of:
to see whether equal comparisons are NULL-safe.
lvca commentedon Oct 13, 2022
I'm guessing the
=operator is not fully supported in our SQL grammar. Any idea @antarcticgiraffe?gramian commentedon Oct 14, 2022
Also, on this issue: the example for
if()is not working as the condition is just a (falsy) string (now).gramian commentedon Nov 9, 2022
Adding to this, I saw in the grammar, that either
=and==are valid tokens. So, if both equality operator are valid,==should be added to the docu (I can do this); and is there a preferred way?lvca commentedon Nov 9, 2022
Correct, OrientDB had it, so we inherited it. Thanks in advance if you want to improve the docs on this!
lvca commentedon Feb 1, 2023
Reproduced, the IF doesn't work at all.
lvca commentedon Feb 1, 2023
I'd also like to import the
eval()function from OrientDB. it can still be useful...feat: supported `eval()` function, fixed function `if()`
lvca commentedon Feb 1, 2023
Fixed.
[-]SQL Comparison in Projections[/-][+]IF function does not work[/+]gramian commentedon Feb 1, 2023
@lvca Cool, also the original problem, comparison in projections, work now. However, all comparison expressions need to be enclosed in parentheses, also inside the
if. I think I will add some examples for this to the docu.lvca commentedon Feb 1, 2023
Yes, using parenthesis is the only way to let the parser understand it's a condition, otherwise, now we have the
eval()in case you want to just use text, or the condition is a property of a record and must be evaluated at run-time. This is useful especially for custom permissions or rulesfeat: supported `eval()` function, fixed function `if()`