use of org.apache.phoenix.pig.util.PhoenixPigSchemaUtil.Dependencies in project phoenix by apache.
the class PhoenixPigSchemaUtilTest method testSchema.
@Test
public void testSchema() throws SQLException, IOException {
final Configuration configuration = mock(Configuration.class);
when(configuration.get(PhoenixConfigurationUtil.SCHEMA_TYPE)).thenReturn(SchemaType.TABLE.name());
final ResourceSchema actual = PhoenixPigSchemaUtil.getResourceSchema(configuration, new Dependencies() {
List<ColumnInfo> getSelectColumnMetadataList(Configuration configuration) throws SQLException {
return Lists.newArrayList(ID_COLUMN, NAME_COLUMN);
}
});
// expected schema.
final ResourceFieldSchema[] fields = new ResourceFieldSchema[2];
fields[0] = new ResourceFieldSchema().setName("ID").setType(DataType.LONG);
fields[1] = new ResourceFieldSchema().setName("NAME").setType(DataType.CHARARRAY);
final ResourceSchema expected = new ResourceSchema().setFields(fields);
assertEquals(expected.toString(), actual.toString());
}
use of org.apache.phoenix.pig.util.PhoenixPigSchemaUtil.Dependencies in project phoenix by apache.
the class PhoenixPigSchemaUtilTest method testUnSupportedTypes.
@Test(expected = IllegalDataException.class)
public void testUnSupportedTypes() throws SQLException, IOException {
final Configuration configuration = mock(Configuration.class);
when(configuration.get(PhoenixConfigurationUtil.SCHEMA_TYPE)).thenReturn(SchemaType.TABLE.name());
PhoenixPigSchemaUtil.getResourceSchema(configuration, new Dependencies() {
List<ColumnInfo> getSelectColumnMetadataList(Configuration configuration) throws SQLException {
return Lists.newArrayList(ID_COLUMN, LOCATION_COLUMN);
}
});
fail("We currently don't support Array type yet. WIP!!");
}
Aggregations