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

SQL: INSERT INTO FROM fails with NPE #1615

Closed
gramian opened this issue May 23, 2024 · 3 comments
Closed

SQL: INSERT INTO FROM fails with NPE #1615

gramian opened this issue May 23, 2024 · 3 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@gramian
Copy link
Collaborator

gramian commented May 23, 2024

ArcadeDB Version:

ArcadeDB Server v24.5.1-SNAPSHOT (build a6fcd5ffcb052e4d1f009093f3cba680bd56c8ce/1716500652832/main)

OS and JDK Version:

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

Expected behavior

Records should be copied into the destination from the source query.

Actual behavior

Internal error Cannot invoke "com.arcadedb.database.Document.getRecord()" because the return value of "com.arcadedb.query.sql.executor.Result.toElement()" is null
Error on command execution (PostCommandHandler)
java.lang.NullPointerException: Cannot invoke "com.arcadedb.database.Document.getRecord()" because the return value of "com.arcadedb.query.sql.executor.Result.toElement()" is null
	at com.arcadedb.query.sql.executor.CopyDocumentStep$1.next(CopyDocumentStep.java:71)
	at com.arcadedb.query.sql.executor.RemoveEdgePointersStep$1.next(RemoveEdgePointersStep.java:51)
	at com.arcadedb.query.sql.executor.SetDocumentStepStep$1.next(SetDocumentStepStep.java:51)
	at com.arcadedb.query.sql.executor.SaveElementStep$1.next(SaveElementStep.java:53)
	at com.arcadedb.query.sql.executor.InsertExecutionPlan.executeInternal(InsertExecutionPlan.java:67)
	at com.arcadedb.query.sql.executor.ScriptLineStep.syncPull(ScriptLineStep.java:47)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.doExecute(ScriptExecutionPlan.java:96)
	at com.arcadedb.query.sql.executor.ScriptExecutionPlan.fetchNext(ScriptExecutionPlan.java:61)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:44)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.executeInternal(SQLScriptQueryEngine.java:218)
	at com.arcadedb.query.sql.SQLScriptQueryEngine.command(SQLScriptQueryEngine.java:108)
	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:134)
	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)

The NPE happens here

Steps to reproduce

CREATE DOCUMENT TYPE src;
CREATE DOCUMENT TYPE dst;

INSERT INTO src SET a = 1;
INSERT INTO src SET a = 2;
INSERT INTO src SET a = 3; 

INSERT INTO dst FROM SELECT a FROM src;
@gramian
Copy link
Collaborator Author

gramian commented May 23, 2024

So the problem seems to be the projection in the query, as

INSERT INTO dst FROM SELECT FROM src;

works, which is tested [here](INSERT INTO dst FROM SELECT FROM src;).

@lvca lvca self-assigned this May 23, 2024
@lvca lvca added the bug Something isn't working label May 23, 2024
@lvca lvca added this to the 24.5.1 milestone May 23, 2024
lvca added a commit that referenced this issue May 23, 2024
@lvca
Copy link
Contributor

lvca commented May 23, 2024

Fixed!

@lvca lvca closed this as completed May 23, 2024
@lvca lvca added the fixed label May 23, 2024
@gramian
Copy link
Collaborator Author

gramian commented May 23, 2024

Works on the example, but also on a large database with query including a filter and an UNWIND! Awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants