Skip to content

Reference memory java $ unable to do math operators. Resulting in ref java memory #1723

Closed

Description

@eisenhaus335

ArcadeDB Version:

"version": "24.1.1 (build 5ecb28ea54dc3e109336645e64794e5eb5ca8ddf/1709313171626/main)"

OS and JDK Version:

Linux 5.15.133.1-microsoft-standard-WSL2 - OpenJDK 64-Bit Server VM 11.0.22

Expected behavior

Doing operators into $ ref memory should been work correctly

Actual behavior

The sql result show is weird java ref memory "com.arcadedb.query.sql.executor.InternalResultSet@52806f961"

Steps to reproduce

begin; let max = SELECT max(seqid) FROM Invoice; let invoice = CREATE VERTEX Invoice (seqid) VALUES ($max + 1); commit retry 100; return $invoice;

Activity

  1. gramian commented on Sep 16, 2024

    @gramian
    Collaborator

    Reproduced, using:

    CREATE VERTEX TYPE Invoice;
    CREATE PROPERTY Invoice.seqid INTEGER;
    
  2. gramian commented on Sep 16, 2024

    @gramian
    Collaborator

    Here is a workaround:

    LET $maxid = SELECT 1 + max(seqid) AS id FROM Invoice;
    LET $invoice = INSERT INTO Invoice SET seqid = $maxid.id[0];
    RETURN $invoice;
    

    Nonetheless, the above behavior needs to be fixed.

    WRT the original code, this works:

    begin;
    let $maxid = SELECT max(seqid) AS id FROM Invoice;
    let $invoice = CREATE VERTEX Invoice (seqid) VALUES ($maxid.id[0] + 1);
    commit retry 100;
    return $invoice;
    
  3. self-assigned this
    on Sep 16, 2024
  4. gramian commented on Sep 16, 2024

    @gramian
    Collaborator

    This seems to reproduce the problem minimally:

    let maxid = SELECT max(seqid) FROM Invoice;
    return $maxid.asString()
    
  5. eisenhaus335 commented on Sep 16, 2024

    @eisenhaus335
    Author
    begin;
    let max = SELECT max(seqid) as id FROM Invoice;
    let invoice = CREATE VERTEX Invoice (seqid) VALUES ($max.id[0].asInteger() + 1);
    commit retry 100;
    return $invoice;
    

    Using this also works. I think arcade query is quite particular that we stores reference as QuerySet. That we need to do with first()/x[0]. The bug seems resulted in query transaction are not converting the value or reference the value. So they operate with the object QuerySet. Maybe, there is no default or dynamic operators that deal between sqlscript expression lines when doing operators

  6. added this to the 26.1.1 milestone on Jan 22, 2026
  7. added
    in progress
    on Jan 22, 2026
  8. self-assigned this
    on Jan 22, 2026
  9. lvca commented on Jan 22, 2026

    @lvca
    Member

    The MathExpression.execute() methods didn't handle cases where operands were InternalResultSet objects (which is what LET variables containing query results are
    stored as). When the operator couldn't perform arithmetic on the InternalResultSet, it fell back to string concatenation.

  10. lvca commented on Jan 22, 2026

    @lvca
    Member

    I added a helper method extractScalarFromResultSet() in MathExpression.java that:

    1. Detects when a value is an InternalResultSet with exactly one result
    2. Checks if that result has exactly one property
    3. If so, extracts and returns the scalar value instead of the ResultSet
  11. added and removed
    in progress
    on Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions