You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Gopal Vijayaraghavan (Jira)" <ji...@apache.org> on 2021/03/16 07:09:00 UTC
[jira] [Commented] (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=17302270#comment-17302270 ]
Gopal Vijayaraghavan commented on HIVE-24888:
---------------------------------------------
Must be related to
{code}
HIVE_STRICT_TIMESTAMP_CONVERSION("hive.strict.timestamp.conversion", true,
"Restricts unsafe numeric to timestamp conversions"),
{code}
Is there an error throwing saying
"Casting NUMERIC types to TIMESTAMP is prohibited ("
> 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)