OrientDB 1.3.0 - using the flatten() function causes no records are returned
Hi, on the latest stable release downloaded from the official site (OrientDB 1.3.0 build 16), I have a simple class: create class Examples;
and inserted some simple test records insert into examples (num) values (2) (3) (4); insert into examples (num) values ("5"); insert into examples (embedded) values ({"name":"James","age":23}); insert into Examples (embset) values ([{"name":"John","age":24},{"name":"Barbara","age":23}]);
so if I perform a query here is the result: orientdb> select from Examples ---+---------+-------------------- #| RID |num ---+---------+-------------------- 0| #12:0|4 1| #12:1|3 2| #12:2|2 3| #12:3|5 4| #12:4|null |{age=23, name=James} 5| #12:5|null |null |[2] ---+---------+--------------------+--------------------+-------------------- 6 item(s) found. Query executed in 0.024 sec(s).
Now if I execute a query with the flatten() function, no records are returned at all. orientdb> select embset from #12:5 ---+---------+-------------------- #| RID |embset ---+---------+-------------------- 0| #-2:1|[2] ---+---------+-------------------- 1 item(s) found. Query executed in 0.012 sec(s).
orientdb> select flatten(embset) from #12:5 0 item(s) found. Query executed in 0.033 sec(s).
I tried to insert the following records too:
orientdb> insert into examples (embset) values ([{"age":12},{"age":13}]) Inserted record 'Examples#12:6{embset:[2]} v0' in 0,001000 sec(s).
orientdb> select flatten(embset) from #12:6 0 item(s) found. Query executed in 0.01 sec(s).
orientdb> insert into examples (embset) values ([2,3,4]) Inserted record 'Examples#12:7{embset:[3]} v0' in 0,001000 sec(s).
orientdb> select flatten(embset) from #12:7 0 item(s) found. Query executed in 0.0010 sec(s).
Have you tried building the latest snapshot and using that? There is a possibility that it could be fixed in the 1.4.0-SNAPSHOT.
To build:
- Clone the source.
- Run
ant clean installg.
If the 1.4.0-SNAPSHOT does not work, post back to this issue :)
Hope that helps :)
I can confirm it does not work neither in 1.3.0 release version nor in the latest snapshot [OrientDB 1.4.0-SNAPSHOT 20130227-0214]
I have tried the following sequence:
create class collection insert into collection set data = [{"size": 0}, {"size": 0}, {"size": 30}]
select flatten(data) from collection result-> empty
Hi, I've fixed a bug in flatten few hours ago. Can you recheck it please?
Lvc@
On 27 February 2013 14:17, dm-ordb [email protected] wrote:
I can confirm it does not work neither in 1.3.0 release version nor in the latest snapshot [OrientDB 1.4.0-SNAPSHOT 20130227-0214]
I have tried the following sequence:
create class collection insert into collection set data = [{"size": 0}, {"size": 0}, {"size": 30}]
select flatten(data) from collection result-> empty
— Reply to this email directly or view it on GitHubhttps://github.com/nuvolabase/orientdb/issues/1332#issuecomment-14173017 .
It has not work yet. But the exceptions are thrown instead empty recordset
- collection of objects
create class collection insert into collection set data = [{"size": 0}, {"size": 0}, {"size": 30}] select flatten(data) from collection
Error: java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable
- map insert into collection set datamap = {"k1": "v", "k2": 0} select flatten(datamap) from collection
Error: java.lang.ClassCastException: java.lang.String cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable
version: OrientDB Server v1.4.0-SNAPSHOT 20130227-1534
The problem here is that map is different by document. You could try this: insert into collection set data = [{"@type":"d","size": 0}, {"@type":"d","size": 0}, {"@type":"d","size": 30}]
This should force to store entries as documents, not maps. However I'd like to support map in flatten as well. Can you post here the full stack trace of the ClassCastException please?
I'm closing this issue. If the problem persists please reopen it rather than create a new one.