Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/SQL: "params" cannot be bucket names #1625

Open
gramian opened this issue Jun 5, 2024 · 6 comments
Open

HTTP/SQL: "params" cannot be bucket names #1625

gramian opened this issue Jun 5, 2024 · 6 comments
Assignees

Comments

@gramian
Copy link
Collaborator

gramian commented Jun 5, 2024

ArcadeDB Version:

ArcadeDB Server v24.6.1-SNAPSHOT (build 6ff2d86d488fe6b3ca20f7a6554160d6017af118/1716919859476/main)

OS and JDK Version:

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

Using a parameter in POST request query where the parameter specifies a bucket name errors. This is maybe because the double colon, ie BUCKET::param cannot be parsed?

Expected behavior

Succesful query in bucket

Actual behavior

Error on command execution
<ArcadeDB_0> Error on command execution (PostQueryHandler)
com.arcadedb.exception.CommandSQLParsingException: SELECT FROM BUCKET::myparam limit 20000
	at com.arcadedb.query.sql.parser.StatementCache.throwParsingException(StatementCache.java:126)
	at com.arcadedb.query.sql.parser.StatementCache.parse(StatementCache.java:116)
	at com.arcadedb.query.sql.parser.StatementCache.get(StatementCache.java:70)
	at com.arcadedb.query.sql.SQLQueryEngine.parse(SQLQueryEngine.java:216)
	at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:80)
	at com.arcadedb.database.LocalDatabase.query(LocalDatabase.java:1378)
	at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:494)
	at com.arcadedb.server.http.handler.PostQueryHandler.executeCommand(PostQueryHandler.java:38)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:113)
	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 <FROM> "FROM" at line 1, column 8.
Was expecting one of:
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    <DISTINCT> ...
    
	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.Projection(SqlParser.java:4892)
	at com.arcadedb.query.sql.parser.SqlParser.SelectWithoutTargetStatement(SqlParser.java:1548)
	at com.arcadedb.query.sql.parser.SqlParser.QueryStatement(SqlParser.java:1497)
	at com.arcadedb.query.sql.parser.SqlParser.StatementInternal(SqlParser.java:1287)
	at com.arcadedb.query.sql.parser.SqlParser.Statement(SqlParser.java:1055)
	at com.arcadedb.query.sql.parser.SqlParser.Parse(SqlParser.java:251)
	at com.arcadedb.query.sql.parser.StatementCache.parse(StatementCache.java:111)
	... 16 more

Steps to reproduce

CREATE DOCUMENT TYPE doc BUCKET mybucket
wget -qO- http://localhost:2480/api/v1/query/test --post-data='{"language":"sql","params":{"myparam":"mybucket"},"command":"SELECT FROM BUCKET::myparam"}' --user root --password arcadedb
@lvca
Copy link
Contributor

lvca commented Jun 5, 2024

It should be BUCKET:myparam

@lvca lvca self-assigned this Jun 5, 2024
@gramian
Copy link
Collaborator Author

gramian commented Jun 5, 2024

Using `BUCKET:myparam` also errors
<ArcadeDB_0> Error on command execution (PostQueryHandler)
com.arcadedb.exception.SchemaException: Bucket with name 'myparam' was not found
	at com.arcadedb.schema.LocalSchema.getBucketByName(LocalSchema.java:281)
	at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleClustersAsTarget(SelectExecutionPlanner.java:2196)
	at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleFetchFromTarget(SelectExecutionPlanner.java:780)
	at com.arcadedb.query.sql.executor.SelectExecutionPlanner.createExecutionPlan(SelectExecutionPlanner.java:144)
	at com.arcadedb.query.sql.parser.SelectStatement.createExecutionPlan(SelectStatement.java:208)
	at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:201)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:85)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:69)
	at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:85)
	at com.arcadedb.database.LocalDatabase.query(LocalDatabase.java:1378)
	at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:494)
	at com.arcadedb.server.http.handler.PostQueryHandler.executeCommand(PostQueryHandler.java:38)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:113)
	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)

since then the parameter is not identified as such.

@lvca
Copy link
Contributor

lvca commented Jun 5, 2024

Sorry, I didn't notice the parameter. Correct, you can't use parameters there.

@gramian
Copy link
Collaborator Author

gramian commented Jun 5, 2024

Too bad. So, does this bug report become a feature request or is this too unlikely to be implemented and should hence be closed?

@gramian
Copy link
Collaborator Author

gramian commented Jun 5, 2024

Hmm, so I tried using

wget -qO- http://localhost:2480/api/v1/query/test --post-data='{"language":"sql","params":{"myparam":"BUCKET:mybucket"},"command":"SELECT FROM :myparam"}' --user root --password arcadedb

which errors, but

wget -qO- http://localhost:2480/api/v1/query/test --post-data='{"language":"sql","params":{"myparam":"doc"},"command":"SELECT FROM :myparam"}' --user root --password arcadedb

works. So can you describe what the syntactic rule is, so I can add it to the docs?

@lvca
Copy link
Contributor

lvca commented Jun 5, 2024

If it works without the BUCKET: prefix, then it should be easy to implement it. I'm ok with this as an enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants