opendistro-for-elasticsearch / sql

🔍 Open Distro SQL Plugin
https://opendistro.github.io/for-elasticsearch/features/SQL%20Support.html
Apache License 2.0
620 stars 186 forks source link

Data type 'Date' backward compatibility issue #1134

Open ankurgupta4891 opened 3 years ago

ankurgupta4891 commented 3 years ago

Prior 1.13 driver release Date type was mapped java.sql.TimeStamp which carries time information but using java.sql.Date drops time information and set values to 00:00:00.000. This makes the driver backward incompatible.

https://github.com/opendistro-for-elasticsearch/sql/blob/7eeb805173196e81b23bd2234a1b626a7233ddae/sql-jdbc/src/main/java/com/amazon/opendistroforelasticsearch/jdbc/types/ElasticsearchType.java#L75

dai-chen commented 3 years ago

I checked the code and the reason of mapping Date to Date after 1.13 is because our new query engine was enabled: https://github.com/opendistro-for-elasticsearch/sql/blob/opendistro-1.13.0.0-rc1/legacy/src/main/java/com/amazon/opendistroforelasticsearch/sql/legacy/plugin/SqlSettings.java#L60.

From then on, original Elasticsearch date is returned as Timestamp because internally Elasticsearch only has epoch. Only date function may return Date type value. Could you please provide test data and query? Need more context to confirm if this is the root cause. Thanks!