You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "Gabriel Reid (JIRA)" <ji...@apache.org> on 2014/03/16 08:22:36 UTC
[jira] [Resolved] (PHOENIX-618) Support negative DATE and TIME
values
[ https://issues.apache.org/jira/browse/PHOENIX-618?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gabriel Reid resolved PHOENIX-618.
----------------------------------
Resolution: Fixed
Bulk resolve of closed issues imported from GitHub. This status was reached by first re-opening all closed imported issues and then resolving them in bulk.
> Support negative DATE and TIME values
> -------------------------------------
>
> Key: PHOENIX-618
> URL: https://issues.apache.org/jira/browse/PHOENIX-618
> Project: Phoenix
> Issue Type: Task
> Affects Versions: 3.0-Release
> Reporter: Artur Denysenko
> Labels: enhancement
>
> I think there is some general problem with date/time/timestamp datatypes and IllegalDataException, but I manage reliably reproduce only this one.
> Try:
> 1. PreparedStatement.setDate("DATE_COLUMN", new java.sql.Date(Long.MIN_VALUE));
> 2. ResultSet.getDate("DATE_COLUMN")
> Works fine for TIMESTAMP and TIME, but not for DATE:
> ```
> com.salesforce.phoenix.schema.IllegalDataException
> at com.salesforce.phoenix.schema.PDataType$UnsignedLongCodec.decodeLong(PDataType.java:3836)
> at com.salesforce.phoenix.schema.PDataType$12.toObject(PDataType.java:1794)
> at com.salesforce.phoenix.schema.PDataType.toObject(PDataType.java:4585)
> at com.salesforce.phoenix.schema.PDataType.toObject(PDataType.java:4564)
> at com.salesforce.phoenix.schema.PDataType.toObject(PDataType.java:4573)
> at com.salesforce.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:85)
> at com.salesforce.phoenix.jdbc.PhoenixResultSet.getDate(PhoenixResultSet.java:332)
> at com.salesforce.phoenix.jdbc.DateColumnTest.test(DateColumnTest.java:41)
> ```
> ```java
> package com.salesforce.phoenix.jdbc;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.PreparedStatement;
> import java.sql.ResultSet;
> import java.sql.SQLException;
> import java.sql.Statement;
> import org.junit.Test;
> public class DateColumnTest {
> @Test
> public void test() throws SQLException {
> Connection con = null;
> try {
> con = DriverManager.getConnection("jdbc:phoenix:cloudera:2181");
> con.setAutoCommit(true);
> Statement stm = con.createStatement();
> stm.execute("DROP TABLE IF EXISTS test.date");
> stm.execute("CREATE TABLE test.date(id BIGINT NOT NULL PRIMARY KEY, t DATE NOT NULL)");
> stm.execute("DELETE FROM test.date");
> stm.close();
> long id = 1;
> PreparedStatement psInsert = con
> .prepareStatement("UPSERT INTO test.date VALUES(?,?)");
> psInsert.setLong(1, id);
> psInsert.setDate(2, new java.sql.Date(Long.MIN_VALUE));
> psInsert.execute();
> psInsert.close();
> PreparedStatement psSelect = con
> .prepareStatement("SELECT * FROM test.date WHERE id=?");
> psSelect.setLong(1, id);
> ResultSet rs = psSelect.executeQuery();
> rs.next();
> rs.getLong(1);
> rs.getDate(2);
> rs.close();
> psSelect.close();
> } finally {
> try {
> con.close();
> } catch (Exception ex) {
> }
> }
> }
> }
> ```
--
This message was sent by Atlassian JIRA
(v6.2#6252)