use of java.sql.DatabaseMetaData in project druid by druid-io.
the class DruidAvaticaHandlerTest method testDatabaseMetaDataColumns.
@Test
public void testDatabaseMetaDataColumns() throws Exception {
final DatabaseMetaData metaData = client.getMetaData();
Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "__time"), Pair.of("DATA_TYPE", Types.TIMESTAMP), Pair.of("TYPE_NAME", "TIMESTAMP"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "cnt"), Pair.of("DATA_TYPE", Types.BIGINT), Pair.of("TYPE_NAME", "BIGINT"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "dim1"), Pair.of("DATA_TYPE", Types.VARCHAR), Pair.of("TYPE_NAME", "VARCHAR"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "dim2"), Pair.of("DATA_TYPE", Types.VARCHAR), Pair.of("TYPE_NAME", "VARCHAR"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "m1"), Pair.of("DATA_TYPE", Types.FLOAT), Pair.of("TYPE_NAME", "FLOAT"), Pair.of("IS_NULLABLE", "NO")), ROW(Pair.of("TABLE_SCHEM", "druid"), Pair.of("TABLE_NAME", "foo"), Pair.of("COLUMN_NAME", "unique_dim1"), Pair.of("DATA_TYPE", Types.OTHER), Pair.of("TYPE_NAME", "OTHER"), Pair.of("IS_NULLABLE", "NO"))), getRows(metaData.getColumns(null, "dr_id", "foo", null), ImmutableSet.of("IS_NULLABLE", "TABLE_NAME", "TABLE_SCHEM", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME")));
}
use of java.sql.DatabaseMetaData in project druid by druid-io.
the class DruidAvaticaHandlerTest method testDatabaseMetaDataCatalogs.
@Test
public void testDatabaseMetaDataCatalogs() throws Exception {
final DatabaseMetaData metaData = client.getMetaData();
Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_CAT", ""))), getRows(metaData.getCatalogs()));
}
use of java.sql.DatabaseMetaData in project druid by druid-io.
the class DruidAvaticaHandlerTest method testDatabaseMetaDataSchemas.
@Test
public void testDatabaseMetaDataSchemas() throws Exception {
final DatabaseMetaData metaData = client.getMetaData();
Assert.assertEquals(ImmutableList.of(ROW(Pair.of("TABLE_CATALOG", ""), Pair.of("TABLE_SCHEM", "druid"))), getRows(metaData.getSchemas(null, "druid")));
}
use of java.sql.DatabaseMetaData in project sharding-jdbc by dangdangdotcom.
the class MasterSlaveDataSourceTest method mockConnection.
private Connection mockConnection(final String dataBaseProductName) throws SQLException {
Connection result = mock(Connection.class);
DatabaseMetaData databaseMetaData = mock(DatabaseMetaData.class);
when(result.getMetaData()).thenReturn(databaseMetaData);
when(databaseMetaData.getDatabaseProductName()).thenReturn(dataBaseProductName);
return result;
}
use of java.sql.DatabaseMetaData in project druid by druid-io.
the class PostgreSQLConnector method canUpsert.
protected boolean canUpsert(Handle handle) throws SQLException {
if (canUpsert == null) {
DatabaseMetaData metaData = handle.getConnection().getMetaData();
canUpsert = metaData.getDatabaseMajorVersion() > 9 || (metaData.getDatabaseMajorVersion() == 9 && metaData.getDatabaseMinorVersion() >= 5);
}
return canUpsert;
}
Aggregations