arcadedb icon indicating copy to clipboard operation
arcadedb copied to clipboard

SQL: Nested Projection Problem

Open gramian opened this issue 1 year ago • 0 comments

ArcadeDB Version:

ArcadeDB Server v24.5.1-SNAPSHOT (build 7872d1acb3616c2866613dabcb7d899322bb3348/1715204385992/main)

OS and JDK Version:

Running on Mac OS X 12.7.4 - OpenJDK 64-Bit Server VM 17.0.11 (Homebrew)

The result of a nested projection produces errors if attempted to process it further. Similarly a nested projection seems not to be allowed inside a LET.

Expected behavior

[{"test":1}]

Actual behavior

Cannot execute command Encountered
Error on command execution (PostCommandHandler)
Exception on parsing the following SQL command: SELECT [{}]:{1 AS test} || [] limit 25;
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.SQLScriptQueryEngine.parseScript(SQLScriptQueryEngine.java:149)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.command(SQLScriptQueryEngine.java:102)
	at com.arcadedb.database.LocalDatabase.command(LocalDatabase.java:1348)
	at com.arcadedb.server.ServerDatabase.command(ServerDatabase.java:472)
	at com.arcadedb.server.http.handler.PostCommandHandler.executeCommand(PostCommandHandler.java:131)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:110)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:100)
	at com.arcadedb.server.http.handler.AbstractServerHttpHandler.handleRequest(AbstractServerHttpHandler.java:127)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: 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.parser.SqlParser.generateParseException(SqlParser.java:27774)
	at com.arcadedb.query.sql.parser.SqlParser.jj_consume_token(SqlParser.java:27619)
	at com.arcadedb.query.sql.parser.SqlParser.ParseScript(SqlParser.java:510)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.parseScript(SQLScriptQueryEngine.java:147)
	... 14 more

Steps to reproduce

SELECT [{}]:{1 AS test} || []
SELECT $a LET $a = [{}]:{1 AS test}

Notably:

SELECT [] || [{}]:{1 AS test}

works, so I think it could be related to the grammar?

gramian avatar May 10 '24 11:05 gramian