Preston Carman created ASTERIXDB-1608:
-----------------------------------------

             Summary: Unexpected result from a join with a Non-Pure function
                 Key: ASTERIXDB-1608
                 URL: https://issues.apache.org/jira/browse/ASTERIXDB-1608
             Project: Apache AsterixDB
          Issue Type: Bug
            Reporter: Preston Carman
            Assignee: Steven Jacobs
            Priority: Minor


The following query should give a unique UUID for each record. The optimizer 
pushes the create-uuid() onto one branch thus resulting in three UUID's instead 
of nine.

Query:
for $x in range(1, 3)
for $y in range(1, 3)
return {"id": create-uuid(), "x": $x};

Result:
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da1"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da1"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da1"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da2"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da2"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da2"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da3"), "x": 3 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da3"), "x": 3 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da3"), "x": 3 }

Expected Result:
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da1"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da2"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da3"), "x": 1 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da4"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da5"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da6"), "x": 2 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da7"), "x": 3 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da8"), "x": 3 }
{ "id": uuid("a5b5cc1e-02e1-8428-cc8e-dcf75d2d4da9"), "x": 3 }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to