You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Anurag Shekhar (Jira)" <ji...@apache.org> on 2021/03/16 08:49:00 UTC

[jira] [Comment Edited] (HIVE-24888) JDBC Query with where clause containing timestamp field in long doesn't return any result.

    [ https://issues.apache.org/jira/browse/HIVE-24888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17302333#comment-17302333 ] 

Anurag Shekhar edited comment on HIVE-24888 at 3/16/21, 8:48 AM:
-----------------------------------------------------------------

There is no exception thrown back to client application.

On beeline

> set hive.strict.timestamp.conversion;
+------------------------------------------------+
| set |
+------------------------------------------------+
| hive.strict.timestamp.conversion is undefined |
+------------------------------------------------+


was (Author: anuragshekhar):
There is no exception thrown back to client application.

> JDBC Query with where clause containing timestamp field in long doesn't return any result.
> ------------------------------------------------------------------------------------------
>
>                 Key: HIVE-24888
>                 URL: https://issues.apache.org/jira/browse/HIVE-24888
>             Project: Hive
>          Issue Type: Bug
>          Components: JDBC
>            Reporter: Anurag Shekhar
>            Priority: Minor
>
> Steps to reproduce
> The following code creates a table with timestamp column and inserts a value, using java.sql.PreparedStament.setLong.
> When same value used to query the table it returns no results. 
> Other variant, using timestamp (setTimestamp) string (setString) works fine.
> {code:java}
> public static void main(String [] args) throws SQLException {
>     TimeZone.setDefault(TimeZone.getTimeZone("IST"));
>     Connection conn = DriverManager.getConnection ("jdbc:hive2://host:port", "hive", "hive");
>     Statement stmt = conn.createStatement();
>     stmt.execute("drop table if exists ts_table");
>     stmt.execute("create table ts_table (ts timestamp) stored as orc");
>     PreparedStatement pStmt = conn.prepareStatement("insert into ts_table (ts) values (?)");
>     long timeStamp = System.currentTimeMillis();
>     pStmt.setLong(1, timeStamp);
>     pStmt.execute();
>     pStmt.close();
>     pStmt = conn.prepareStatement("select * from ts_table where ts = ?");
>     pStmt.setLong(1, timeStamp);
>     ResultSet rs = pStmt.executeQuery();
>     if (rs.next()) {
>         Timestamp resultTs = rs.getTimestamp(1);
>         System.out.println("Retrieved " + resultTs + " In millis " + resultTs.getTime());
>         System.out.println("where ts = " + timeStamp);
>     }
>     else
>         System.out.println ("No result where ts = " + timeStamp);
>     rs.close();
>     pStmt.close();
>     conn.close();
> }{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)