Skip to content
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

The following error message appears when executing an SQL statement with an ORDER BY clause in Oracle: "Order by value must implement Comparable." #33678

Open
NjuptMei opened this issue Nov 15, 2024 · 1 comment

Comments

@NjuptMei
Copy link

Which version of ShardingSphere did you use?

shardingsphere Ver. shardingsphere, 5.4.1
oracle Ver. oracle12c
ojdbc Ver. ojdbc8

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

config:
actualDataNodes: ds0.dmg_kettle_conf, ds0.dmg_kettle_config_dmgtmp
logicTable: dmg_kettle_config
behavior:
when executing SQL "select * from dmg_kettle_config order by create_timstmp desc", except the ordered result, the dataTye of create_timstmp is TimeStamp With Time Zone, (doesn't support this dataType?)

Actual behavior

when executing SQL "select * from dmg_kettle_config order by create_timstmp desc", the error message "Order by value must implement Comparable." occurs

Reason analyze (If you can)

When executing query, in oracle.jdbc.driver.OracleResultSetMetaData.getColumnType, the create_timstmp dataType is 181, and mappings to code -101
image
and in shardingJdbc, when merging resut, it only transfer the code 93 to java.sql.Timestamp, but the code -101 convert to Object:
org.apache.shardingsphere.sharding.execute.sql.execute.result.MemoryQueryResult.getRows(ResultSet resultSet)
image
so, when code running the order executor: org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValues(), cause this error.
image
btw: Setting the following parameter: System.getProperties().setProperty("oracle.jdbc.J2EE13Compliant", "true") is ineffective.

https://shardingsphere.apache.org/document/4.1.1/en/faq/#10-why-does-oracle-database-throw-order-by-value-must-implements-comparable-exception-when-using-timestamp-order-by

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

SQL "select * from dmg_kettle_config order by create_timstmp desc", create_timstmp is TimeStamp With Time Zone, (doesn't support this dataType?)

Example codes for reproduce this issue (such as a github link).

@terrymanu
Copy link
Member

The version you provided is 5.4.1, but the document you provided is 4.1.1.
Is it a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants