Search in sources :

Example 1 with PInteger

use of org.apache.phoenix.schema.types.PInteger in project phoenix by apache.

the class QueryCompilerTest method testColumnProjectionUnionAll.

@Test
public void testColumnProjectionUnionAll() throws SQLException {
    Connection conn = DriverManager.getConnection(getUrl());
    try {
        conn.createStatement().execute("CREATE TABLE t1(k INTEGER PRIMARY KEY," + " col1 CHAR(8), col2 VARCHAR(10), col3 decimal(10,2))");
        conn.createStatement().execute("CREATE TABLE t2(k TINYINT PRIMARY KEY," + " col1 CHAR(20), col2 CHAR(30), col3 double)");
        QueryPlan plan = getQueryPlan("SELECT * from t1 union all select * from t2", Collections.emptyList());
        RowProjector rowProj = plan.getProjector();
        assertTrue(rowProj.getColumnProjector(0).getExpression().getDataType() instanceof PInteger);
        assertTrue(rowProj.getColumnProjector(1).getExpression().getDataType() instanceof PChar);
        assertTrue(rowProj.getColumnProjector(1).getExpression().getMaxLength() == 20);
        assertTrue(rowProj.getColumnProjector(2).getExpression().getDataType() instanceof PVarchar);
        assertTrue(rowProj.getColumnProjector(2).getExpression().getMaxLength() == 30);
        assertTrue(rowProj.getColumnProjector(3).getExpression().getDataType() instanceof PDecimal);
        assertTrue(rowProj.getColumnProjector(3).getExpression().getScale() == 2);
    } finally {
        conn.close();
    }
}
Also used : PChar(org.apache.phoenix.schema.types.PChar) PInteger(org.apache.phoenix.schema.types.PInteger) PDecimal(org.apache.phoenix.schema.types.PDecimal) Connection(java.sql.Connection) PhoenixConnection(org.apache.phoenix.jdbc.PhoenixConnection) PVarchar(org.apache.phoenix.schema.types.PVarchar) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Aggregations

Connection (java.sql.Connection)1 PhoenixConnection (org.apache.phoenix.jdbc.PhoenixConnection)1 BaseConnectionlessQueryTest (org.apache.phoenix.query.BaseConnectionlessQueryTest)1 PChar (org.apache.phoenix.schema.types.PChar)1 PDecimal (org.apache.phoenix.schema.types.PDecimal)1 PInteger (org.apache.phoenix.schema.types.PInteger)1 PVarchar (org.apache.phoenix.schema.types.PVarchar)1 Test (org.junit.Test)1