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

James Taylor commented on PHOENIX-2505:
---------------------------------------

[~jelenaf] - I'm not able to reproduce this. Below is the test that I dropped 
into GroupByCaseIT and it passes. Please let me know if you're able to repro it 
and if so how.
{code}
    @Test
    public void testBooleanInGroupBy() throws Exception {
        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
        Connection conn = DriverManager.getConnection(getUrl(), props);
        String ddl = " create table bool_gb(id varchar primary key,v1 boolean, 
v2 integer, v3 integer)";

        createTestTable(getUrl(), ddl);
        String dml = "UPSERT INTO bool_gb VALUES(?,?,?,?)";
        PreparedStatement stmt = conn.prepareStatement(dml);
        stmt.setString(1, "a");
        stmt.setBoolean(2, false);
        stmt.setInt(3, 1);
        stmt.setInt(4, 1);
        stmt.execute();
        stmt.setString(1, "b");
        stmt.setBoolean(2, false);
        stmt.setInt(3, 2);
        stmt.setInt(4, 2);
        stmt.execute();
        stmt.setString(1, "c");
        stmt.setBoolean(2, true);
        stmt.setInt(3, 3);
        stmt.setInt(4, 3);
        stmt.execute();
        conn.commit();

        String[] gbs = {"v1,v2,v3","v1,v3,v2","v2,v1,v3"};
        for (String gb : gbs) {
            ResultSet rs = conn.createStatement().executeQuery("SELECT v1, v2, 
v3 from bool_gb group by " + gb);
            assertTrue(rs.next());
            assertEquals(false,rs.getBoolean("v1"));
            assertEquals(1,rs.getInt("v2"));
            assertEquals(1,rs.getInt("v3"));
            assertTrue(rs.next());
            assertEquals(false,rs.getBoolean("v1"));
            assertEquals(2,rs.getInt("v2"));
            assertEquals(2,rs.getInt("v3"));
            assertTrue(rs.next());
            assertEquals(true,rs.getBoolean("v1"));
            assertEquals(3,rs.getInt("v2"));
            assertEquals(3,rs.getInt("v3"));
            assertFalse(rs.next());
            rs.close();
        }
        conn.close();
    }
{code}

> Unexpected error caused by GROUP BY
> -----------------------------------
>
>                 Key: PHOENIX-2505
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2505
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Jelena
>            Assignee: James Taylor
>            Priority: Minor
>             Fix For: 4.7.0
>
>
> If you are selecting more than 2 rows, and you have a Boolean and any number 
> type, depending on the order in which you put them in the GROUP BY clause, 
> you get the following error:
> {noformat}Error during Execute
> org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type 
> mismatch. DECIMAL cannot be coerced to BOOLEAN
> {noformat}
> Some examples:
> Order that throws error:
> GROUP BY    NUMBER_TYPE,    BOOLEAN,     ANY_TYPE
> GROUP BY    BOOLEAN,     NUMBER_TYPE,     ANY_TYPE
> GROUP BY    BOOLEAN,     ANY_TYPE,     NUMBER_TYPE
> Order that does not throw the error:
> GROUP BY   NUMBER_TYPE,    ANY_TYPE,      BOOLEAN
> GROUP BY   NON_NUMBER_TYPE,     BOOLEAN,    NUMBER_TYPE  ==> NOTE: there can 
> be any number of NON_NUMBER_TYPE columns before the first one
> GROUP BY   NON_BOOLEAN_TYPE,    NUMBER_TYPE,     BOOLEAN   ==> NOTE: there 
> can be any number of NON_BOOLEAN_TYPE columns before the NUMBER_TYPE
>  
> Note: This is not dependent on the order in which the columns are selected



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to