Skip to content

Executing a query with a condition on an embedded object results in an error unless detailed profiling is enabled. #1117

@alan-strickland-red

Description

@alan-strickland-red

ArcadeDB Version:

v23.6.1-SNAPSHOT (build 5f625e9/1686275898214/main)

OS and JDK Version:

Running on Linux 5.10.102.1-microsoft-standard-WSL2 - OpenJDK 64-Bit Server VM 11.0.19 (Temurin-11.0.19+7)

Expected behavior

Successful execution of the query returning the results that matches the json.

Actual behavior

An exception occurs unless detailed profiling is enabled.

{
  "error": "Internal error",
  "detail": "arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, com.arcadedb.query.sql.parser.SimpleNode",
  "exception": "java.lang.ArrayStoreException"
}

Steps to reproduce

  1. Setup a simple type with an embedded property.
CREATE DOCUMENT TYPE TestObjectEquals IF NOT EXISTS;
CREATE PROPERTY TestObjectEquals.obj EMBEDDED;
INSERT INTO TestObjectEquals(obj) VALUES({"a":"1"});
  1. Execute the following query over HTTP without profiling and note the exception.
SELECT FROM TestObjectEquals WHERE obj = {"a":"1"}
curl  -X POST \
  'http://localhost:2480/api/v1/query/db' \
  --header 'Accept: */*' \
  --header 'Authorization: Basic ****' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "language": "sql",
  "command": "SELECT FROM `TestObjectEquals` WHERE  `obj` = {\"a\":\"1\"}"
}'
2023-06-09 16:54:00 <ArcadeDB_0> Error on command execution (PostCommandHandler)
2023-06-09 16:54:00 java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, com.arcadedb.query.sql.parser.SimpleNode
2023-06-09 16:54:00     at java.base/java.lang.System.arraycopy(Native Method)
2023-06-09 16:54:00     at java.base/java.util.ArrayList.toArray(ArrayList.java:433)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.Json.getCacheableElements(Json.java:164)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:159)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SimpleNode.isCacheable(SimpleNode.java:160)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SelectStatement.executionPlanCanBeCached(SelectStatement.java:165)
2023-06-09 16:54:00     at com.arcadedb.query.sql.executor.SelectExecutionPlanner.createExecutionPlan(SelectExecutionPlanner.java:118)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SelectStatement.createExecutionPlan(SelectStatement.java:212)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:206)
2023-06-09 16:54:00     at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:73)
2023-06-09 16:54:00     at com.arcadedb.query.sql.SQLQueryEngine.command(SQLQueryEngine.java:101)
2023-06-09 16:54:00     at com.arcadedb.database.EmbeddedDatabase.command(EmbeddedDatabase.java:1291)
2023-06-09 16:54:00     at com.arcadedb.server.ServerDatabase.command(ServerDatabase.java:446)
2023-06-09 16:54:00     at com.arcadedb.server.http.handler.PostCommandHandler.executeCommand(PostCommandHandler.java:121)
2023-06-09 16:54:00     at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:87)
2023-06-09 16:54:00     at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:98)
2023-06-09 16:54:00     at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:127)
2023-06-09 16:54:00     at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
2023-06-09 16:54:00     at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
2023-06-09 16:54:00     at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
2023-06-09 16:54:00     at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
2023-06-09 16:54:00     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
2023-06-09 16:54:00     at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
2023-06-09 16:54:00     at java.base/java.lang.Thread.run(Thread.java:829)
  1. Execute the same query over HTTP with profiling and the results are returned as expected.
curl  -X POST \
  'http://localhost:2480/api/v1/query/db' \
  --header 'Accept: */*' \
  --header 'Authorization: Basic ****' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "language": "sql",
  "command": "SELECT FROM `TestObjectEquals` WHERE  `obj` = {\"a\":\"1\"}"
  "profileExecution": "detailed"
}'
{
  "user": "root",
  "version": "23.6.1-SNAPSHOT (build 5f625e9c1cfa44b7df750372260303ec485d39e5/1686275898214/main)",
  "serverName": "ArcadeDB_0",
  "result": [
    {
      "@rid": "#63422:0",
      "@type": "TestObjectEquals",
      "@cat": "d",
      "obj": {
        "a": "1"
      }
    }
  ],
  "explain": "+ FETCH FROM TYPE TestObjectEquals (126μs)\n  + FETCH FROM BUCKET 63421 (TestObjectEquals_0) ASC (11μs)\n  + FETCH FROM BUCKET 63422 (TestObjectEquals_1) ASC (66μs)\n  + FETCH FROM BUCKET 63423 (TestObjectEquals_2) ASC (14μs)\n  + FETCH FROM BUCKET 63424 (TestObjectEquals_3) ASC (8μs)\n  + FETCH FROM BUCKET 63425 (TestObjectEquals_4) ASC (6μs)\n  + FETCH FROM BUCKET 63426 (TestObjectEquals_5) ASC (6μs)\n  + FETCH FROM BUCKET 63427 (TestObjectEquals_6) ASC (6μs)\n  + FETCH FROM BUCKET 63428 (TestObjectEquals_7) ASC (6μs)\n+ FILTER ITEMS WHERE  (53μs)\n  `obj` = {\"a\": \"1\"}\n+ LIMIT ( LIMIT 20000)"
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions