Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/52#discussion_r26907122
  
    --- Diff: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java ---
    @@ -176,4 +177,60 @@ public void 
testToDate_CustomTimeZoneViaQueryServicesAndCustomFormat() throws SQ
                     callToDateFunction(
                             customTimeZoneConn, "TO_DATE('1970-01-01', 
'yyyy-MM-dd')").getTime());
         }
    +    
    +    @Test
    +    public void testTimestampCast() throws SQLException {
    +        Properties props = new Properties();
    +        props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, 
"GMT+1");
    +        Connection customTimeZoneConn = 
DriverManager.getConnection(getUrl(), props);
    +
    +        assertEquals(
    +            1426188807198L,
    +                callToDateFunction(
    +                        customTimeZoneConn, "CAST(1426188807198 AS 
TIMESTAMP)").getTime());
    +        
    +
    +        try {
    +            callToDateFunction(
    +                    customTimeZoneConn, "CAST(22005 AS TIMESTAMP)");
    +            fail();
    +        } catch (TypeMismatchException e) {
    +
    +        }
    +    }
    +    
    +    @Test
    +    public void testUnsignedLongToTimestampCast() throws SQLException {
    +        Properties props = new Properties();
    +        props.setProperty(QueryServices.DATE_FORMAT_TIMEZONE_ATTRIB, 
"GMT+1");
    +        Connection conn = DriverManager.getConnection(getUrl(), props);
    +        conn.setAutoCommit(false);
    +        try {
    +            conn.prepareStatement(
    +                "create table TT("
    +                        + "a unsigned_int not null, "
    +                        + "b unsigned_int not null, "
    +                        + "ts unsigned_long not null "
    +                        + "constraint PK primary key (a, b, 
ts))").execute();
    +            conn.commit();
    --- End diff --
    
    FYI, no need for commit after DDL statements.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to