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();
}
}
Aggregations