-
Notifications
You must be signed in to change notification settings - Fork 872
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
OrientDB 1.6.3: ClassCastException expanding a field (OTrackedMap, OIdentifiable) #2044
Comments
players seems to be a map. If you want to use as target of another select (like the one with expand()) you should call it against players.values() to return the collection of values. |
Hi Luca,
|
By looking at your JSON that isn't a MAP but a collection. So I don't know why a OTrackedMap object goes there. Could you debug in what case that OTrackedMap object goes in tempResult variable of the SQL select command? |
Ok, I will try it |
Hi,
the problem is generated by the method OCommandExecutorSQLResultsetAbstract.evaluateRecord(), at this line:
The problem is that in this case the evaluate() method does not return a Boolean but an instance of OTrackedMap.
Actually operator is null and since l is not null l itself is returned. OSQLFilterCondition.evaluate(OIdentifiable, ODocument, Object, OCommandContext) line: 296 and generates the ClassCastExeption error. Actually it seems that the variable tempResult is never involved. |
Probably after the return that Map goes in the tempResult. So why are you writing a query like that? |
I just want to extract all records that contain at least one player with the given email address. |
Why don't you use:
|
it returns no records |
Ok, I digged into the code. I think that the problem is in OSQLFilterItemField.getValue().
At line 62:
the method getFieldValue() returns null and then all the statement is evaluated as false. In other words the filed "username" isn't found inside the record |
Can you provide a fix for it? Or a database to debug on that point? |
Those methods are the focal points of the SQL parser, I woudn't make some damage making something wrong. |
Hi!
I am facing with a very weird behaviour of a select statement.
I cannot execute expand() or contains() function because a ClassCastException is raised or no records at all are returned.
I have a "games" class that for out test, at the moment contains just one record:
"@Rid": "#24:0",
"@Version": 2,
"@Class": "games",
"players": [
{
"username": "[email protected]",
"name": "john doe",
"points": 0
},
{
"username": "[email protected]",
"name": "jane doe",
"department": "one",
"points": 0
},
{
"username": "[email protected]",
"name": "dana scully",
"department": "two",
"points": 0
}
],
"status": "open",
"player_turn": 0,
"id": "ff342a9b-79cd-4494-983e-6ec4a1a47c8a",
"_creation_date": "2014-02-15T13:49:51.051+0100",
"_author": "admin"
As you can see the field "players" is a collection of JSON objects.
If I perform a query against the class I have:
orientdb> select from games
----+-----+-------+------+-----------+------------------------------------+-------+------+------+----------------------------+-------
|@Rid |players|status|player_turn|id |_links |_audit|_allow|_creation_date |_author
----+-----+-------+------+-----------+------------------------------------+-------+------+------+----------------------------+-------
0 |#24:0|[3] |open |0 |ff342a9b-79cd-4494-983e-6ec4a1a47c8a|#11:383|#3:370|[1] |2014-02-15T13:49:51.051+0100|admin
----+-----+-------+------+-----------+------------------------------------+-------+------+------+----------------------------+-------
or:
orientdb> select @this.toJson() from games
----+-----+-----------------------------------------------------------------------------------------------------------------
|@Rid |this
----+-----+-----------------------------------------------------------------------------------------------------------------
0 |#-2:1|{"@type":"d","@Rid":"#24:0","@Version":2,"@Class":"games","players":[{"username":"[email protected]","name":"john ...
----+-----+-----------------------------------------------------------------------------------------------------------------
1 item(s) found. Query executed in 0.041 sec(s).
Everything seems to be fine.
However when I try to expand the players field I have this error:
orientdb> select expand(players) from games
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select expand(players) from games
Error: java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to com.orientechnologies.orient.core.db.re
cord.OIdentifiable
Furthermore I cannot execute any selection criteria against the players field:
orientdb> select from games where players contains (username = "[email protected]")
0 item(s) found. Query executed in 0.0020 sec(s).
orientdb> select from games where players[username] = "[email protected]"
0 item(s) found. Query executed in 0.0040 sec(s).
orientdb> select from games where players[username = "[email protected]"]
Error: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select from games where players[user
name = "[email protected]"]
Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select expand(players) from games
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:102)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:85)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:82)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:29)
... 26 more
Caused by: java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to com.orientechnologies.orient.core.d
b.record.OIdentifiable
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.getResult(OCommandExecutorSQLResultsetAbstract.java:163)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:340)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:57)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:96)
... 30 more
and this is the second one:
Caused by: com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select from games where ( players[username="[email protected]"] )
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:102)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:85)
at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69)
at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:82)
at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:29)
... 26 more
Caused by: java.lang.ClassCastException: com.orientechnologies.orient.core.db.record.OTrackedMap cannot be cast to java.lang.Boolean
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.evaluateRecord(OCommandExecutorSQLResultsetAbstract.java:317)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLResultsetAbstract.filter(OCommandExecutorSQLResultsetAbstract.java:310)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.executeSearchRecord(OCommandExecutorSQLSelect.java:401)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.executeSearch(OCommandExecutorSQLSelect.java:364)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:333)
at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:57)
at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:96)
... 30 more
The text was updated successfully, but these errors were encountered: