hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeff saremi <jeffsar...@hotmail.com>
Subject Baffling situation with tableExists and createTable
Date Tue, 25 Apr 2017 23:05:56 GMT
I have a super simple piece of code which tries to create a test table if it does not exist

calling admin.tableExists(TableName.valueOf(table)) returns false causing the control to be
passed to the line that creates it admin.createTable(tableDescriptor). Then i get an exception
that the table exists!

Exception in thread "main" org.apache.hadoop.hbase.TableExistsException: LoadTest


String table = config.tableName;
...
Connection conn = ConnectionFactory.createConnection(hbaseconf);
Admin admin = conn.getAdmin();
if(!admin.tableExists(TableName.valueOf(table))) {
    Log.info("table " + table + " does not exist. Creating it...");
    HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf(table));
    tableDescriptor.addFamily(new HColumnDescriptor(config.FAMILY));
    admin.createTable(tableDescriptor);
}

Jeff

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message