Shall I log this as a bug?

On Wednesday, January 25, 2017 at 10:31:04 PM UTC-8, Borov wrote:
>
> I have a strange issue. I need to run a query with a sub-query to select a 
> record. I used the LET statement for the sub-query. When the query executes 
> I do get the correct result, but each time OrientDB server throws an error 
> in its console. Complaints about casting data type for the index. 
>
> To demonstrate and replicate the problem I have recreated this condition 
> with 2 simple tables, so you can quickly reproduce it.
>
> Script to recreate the issue
>
> create class Acc extends V
> create property Acc.name STRING
>
> create class Year extends V
> create property Year.account LINK Acc (NOTNULL TRUE, MANDATORY TRUE)
> create property Year.value INTEGER (NOTNULL TRUE, MANDATORY TRUE)
>
> // Indexes (allow only a single year per account)
> create index UniqueAccLeadYear on Year (account, value) UNIQUE
>
> Steps to reproduce the exception:
>
> orientdb {db=Customers}> info class Acc
> CLASS 'Acc'
>
> Records..............: 0
> Super classes........: [V]
> Default cluster......: acc (id=249)
> Supported clusters...: acc(249), acc_1(250), acc_2(251), acc_3(252)
> Cluster selection....: round-robin
> Oversize.............: 0.0
>
> PROPERTIES
>
> +----+----+------+-----------------+---------+--------+--------+----+----+-------+-------+
> |#   |NAME|TYPE  |LINKED-TYPE/CLASS|MANDATORY|READONLY|NOT-NULL|MIN |MAX 
> |COLLATE|DEFAULT|
>
> +----+----+------+-----------------+---------+--------+--------+----+----+-------+-------+
> |0   |name|STRING|                 |false    |false   |false   |    |    |
> default|       |
>
> +----+----+------+-----------------+---------+--------+--------+----+----+-------+-------+
>
> orientdb {db=Customers}> info class Year
> CLASS 'Year'
>
> Records..............: 0
> Super classes........: [V]
> Default cluster......: year (id=265)
> Supported clusters...: year(265), year_1(266), year_2(267), year_3(268)
> Cluster selection....: round-robin
> Oversize.............: 0.0
>
> PROPERTIES
>
> +----+-------+-------+-----------------+---------+--------+--------+----+----+-------+-------+
> |#   |NAME   |TYPE   |LINKED-TYPE/CLASS|MANDATORY|READONLY|NOT-NULL|MIN 
> |MAX |COLLATE|DEFAULT|
>
> +----+-------+-------+-----------------+---------+--------+--------+----+----+-------+-------+
> |0   |value  |INTEGER|                 |true     |false   |true    |    | 
>    |default|       |
> |1   |account|LINK   |Acc              |true     |false   |true    |    | 
>    |default|       |
>
> +----+-------+-------+-----------------+---------+--------+--------+----+----+-------+-------+
>
> INDEXES (1 altogether)
> +----+-----------------+---------------+
> |#   |NAME             |PROPERTIES     |
> +----+-----------------+---------------+
> |0   |UniqueAccLeadYear|[account,value]|
> +----+-----------------+---------------+
>
> orientdb {db=Customers}> insert into Acc set name = 'Account 1'
> Inserted record 'Acc#249:0{name:Account 1} v1' in 0.004000 sec(s).
>
> orientdb {db=Customers}> insert into Year set value = 2017, account = 
> #249:0
> Inserted record 'Year#265:0{value:2017,account:#249:0} v1' in 0.003000 sec
> (s).
>
> orientdb {db=Customers}> select from Acc
> +----+------+------+---------+
> |#   |@RID  |@CLASS|name     |
> +----+------+------+---------+
> |0   |#249:0|Acc   |Account 1|
> +----+------+------+---------+
>
> orientdb {db=Customers}> select from Year
> +----+------+------+-----+-------+
> |#   |@RID  |@CLASS|value|account|
> +----+------+------+-----+-------+
> |0   |#265:0|Year  |2017 |#249:0 |
> +----+------+------+-----+-------+
>
> orientdb {db=Customers}> SELECT FROM Year LET $account = (SELECT FROM #249:0) 
> WHERE value = 2017 AND account = $account[0].@rid
> +----+------+------+-----+-------+
> |#   |@RID  |@CLASS|value|account|
> +----+------+------+-----+-------+
> |0   |#265:0|Year  |2017 |#249:0 |
> +----+------+------+-----+-------+
>
> When executing the last query I get this exception in the DB console
>
> $ANSI{green {db=Customers}} Error on using index UniqueAccLeadYear in 
> query 'SELECT FROM Year LET $account = (SELECT FROM #249:0) WHERE value = 
> 2017 AND account = $account[0].@rid'. Probably you need to rebuild indexes
> . Now executing query using cluster scan
> java.lang.ClassCastException: java.lang.Integer cannot be cast to com.
> orientechnologies.orient.core.db.record.OIdentifiable
>  at com.orientechnologies.orient.core.serialization.serializer.binary.impl
> .OLinkSerializer.preprocess(OLinkSerializer.java:44)
>  at com.orientechnologies.orient.core.serialization.serializer.binary.impl
> .index.OCompositeKeySerializer.preprocess(OCompositeKeySerializer.java:283
> )
>  at com.orientechnologies.orient.core.serialization.serializer.binary.impl
> .index.OCompositeKeySerializer.preprocess(OCompositeKeySerializer.java:46)
>  at com.orientechnologies.orient.core.index.sbtree.local.OSBTree.
> iterateEntriesBetweenAscOrder(OSBTree.java:1474)
>  at com.orientechnologies.orient.core.index.sbtree.local.OSBTree.
> iterateEntriesBetween(OSBTree.java:771)
>  at com.orientechnologies.orient.core.index.engine.OSBTreeIndexEngine.
> iterateEntriesBetween(OSBTreeIndexEngine.java:185)
>  at com.orientechnologies.orient.core.storage.impl.local.
> OAbstractPaginatedStorage.doIterateIndexEntriesBetween(
> OAbstractPaginatedStorage.java:2042)
>  at com.orientechnologies.orient.core.storage.impl.local.
> OAbstractPaginatedStorage.iterateIndexEntriesBetween(
> OAbstractPaginatedStorage.java:2030)
>  at com.orientechnologies.orient.core.index.OIndexOneValue.
> iterateEntriesBetween(OIndexOneValue.java:205)
>  at com.orientechnologies.orient.core.index.OIndexAbstractDelegate.
> iterateEntriesBetween(OIndexAbstractDelegate.java:104)
>  at com.orientechnologies.orient.core.index.OIndexTxAwareOneValue.
> iterateEntriesBetween(OIndexTxAwareOneValue.java:292)
>  at com.orientechnologies.orient.core.sql.operator.OQueryOperatorEquals.
> executeIndexQuery(OQueryOperatorEquals.java:173)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.
> searchForIndexes(OCommandExecutorSQLSelect.java:2184)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.
> searchInClasses(OCommandExecutorSQLSelect.java:1001)
>  at com.orientechnologies.orient.core.sql.
> OCommandExecutorSQLResultsetAbstract.assignTarget(
> OCommandExecutorSQLResultsetAbstract.java:209)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.
> assignTarget(OCommandExecutorSQLSelect.java:530)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.
> executeSearch(OCommandExecutorSQLSelect.java:512)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.
> execute(OCommandExecutorSQLSelect.java:488)
>  at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.
> execute(OCommandExecutorSQLDelegate.java:74)
>  at com.orientechnologies.orient.core.storage.impl.local.
> OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:
> 2592)
>  at com.orientechnologies.orient.core.storage.impl.local.
> OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:2538)
>  at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.
> execute(OCommandRequestTextAbstract.java:69)
>  at com.orientechnologies.orient.server.network.protocol.http.command.post
> .OServerCommandPostCommand.execute(OServerCommandPostCommand.java:106)
>  at com.orientechnologies.orient.graph.server.command.
> OServerCommandPostCommandGraph.execute(OServerCommandPostCommandGraph.java
> :37)
>  at com.orientechnologies.orient.server.network.protocol.http.
> ONetworkProtocolHttpAbstract.service(ONetworkProtocolHttpAbstract.java:169
> )
>  at com.orientechnologies.orient.server.network.protocol.http.
> ONetworkProtocolHttpAbstract.execute(ONetworkProtocolHttpAbstract.java:622
> )
>  at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:
> 77)
>
> I tried different variations of the query with no avail. When query is 
> correct it does return the result as expected, but exception always thrown. 
> I tried rebuilding the index and recreating tables, but all the same.
>
> If I hardcode the Acc RID then the query produces result and no exception 
> is thrown. Like this:
>
> SELECT FROM Year LET $account = (SELECT FROM #249:0) WHERE value = 2017 
> AND account = #249:0
>
> Am I doing something wrong with the LET variable, incorrectly accessing 
> the account RID or is it a bug?
>
> Thanks,
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to