@Override
  public void preCreateTable(Table tbl) throws MetaException {
    // We'd like to move this to HiveMetaStore for any non-native table, but
    // first we need to support storing NULL for location on a table
    if (tbl.getSd().getLocation() != null) {
      throw new MetaException("LOCATION may not be specified for HBase.");
    }
    // we shouldn't delete the hbase table in case of CREATE TABLE ... LIKE (CTLT) failures since we'd remove the
    // hbase table for the original table too. Let's save the value of CTLT here, because this param will be gone
    isCTLT = Optional.ofNullable(tbl.getParameters())
        .map(params -> params.get(TABLE_IS_CTLT))
        .map(Boolean::parseBoolean)
        .orElse(false);

    org.apache.hadoop.hbase.client.Table htable = null;

    try {
      String tableName = getHBaseTableName(tbl);
      Map<String, String> serdeParam = tbl.getSd().getSerdeInfo().getParameters();
      String hbaseColumnsMapping = serdeParam.get(HBaseSerDe.HBASE_COLUMNS_MAPPING);

      ColumnMappings columnMappings = HBaseSerDe.parseColumnsMapping(hbaseColumnsMapping);

      HTableDescriptor tableDesc;

      if (!getHBaseAdmin().tableExists(TableName.valueOf(tableName))) {
        // create table from Hive
        // create the column descriptors
        tableDesc = new HTableDescriptor(TableName.valueOf(tableName));
        Set<String> uniqueColumnFamilies = new HashSet<String>();

        for (ColumnMappings.ColumnMapping colMap : columnMappings) {
          if (!colMap.hbaseRowKey && !colMap.hbaseTimestamp) {
            uniqueColumnFamilies.add(colMap.familyName);
          }
        }

        for (String columnFamily : uniqueColumnFamilies) {
          tableDesc.addFamily(new HColumnDescriptor(Bytes.toBytes(columnFamily)));
        }

        getHBaseAdmin().createTable(tableDesc);
      } else {
        // register table in Hive
        // make sure the schema mapping is right
        tableDesc = getHBaseAdmin().getTableDescriptor(TableName.valueOf(tableName));

        for (ColumnMappings.ColumnMapping colMap : columnMappings) {

          if (colMap.hbaseRowKey || colMap.hbaseTimestamp) {
            continue;
          }

          if (!tableDesc.hasFamily(colMap.familyNameBytes)) {
            throw new MetaException("Column Family " + colMap.familyName
                + " is not defined in hbase table " + tableName);
          }
        }
      }

      // ensure the table is online
      htable = getHBaseAdmin().getConnection().getTable(tableDesc.getTableName());
    } catch (Exception se) {
      throw new MetaException(StringUtils.stringifyException(se));
    } finally {
      if (htable != null) {
        IOUtils.closeQuietly(htable);
      }
    }
  }
MetaHook for HBase. Updates the table data in HBase too. Not thread safe, and cleanup should
be used after usage.
hbase-handler/src/java/org/apache/hadoop/hive/hbase/HBaseMetaHook.java