public void createTable(Table tbl, boolean ifNotExists,
    List<SQLPrimaryKey> primaryKeys,
    List<SQLForeignKey> foreignKeys,
    List<SQLUniqueConstraint> uniqueConstraints,
    List<SQLNotNullConstraint> notNullConstraints,
    List<SQLDefaultConstraint> defaultConstraints,
    List<SQLCheckConstraint> checkConstraints)
            throws HiveException {
    try {
      if (org.apache.commons.lang3.StringUtils.isBlank(tbl.getDbName())) {
        tbl.setDbName(SessionState.get().getCurrentDatabase());
      }
      if (tbl.getCols().size() == 0 || tbl.getSd().getColsSize() == 0) {
        tbl.setFields(HiveMetaStoreUtils.getFieldsFromDeserializer(tbl.getTableName(), tbl.getDeserializer(), conf));
      }
      tbl.checkValidity(conf);
      if (tbl.getParameters() != null) {
        tbl.getParameters().remove(hive_metastoreConstants.DDL_TIME);
      }
      org.apache.hadoop.hive.metastore.api.Table tTbl = tbl.getTTable();
      PrincipalPrivilegeSet principalPrivs = new PrincipalPrivilegeSet();
      SessionState ss = SessionState.get();
      if (ss != null) {
        CreateTableAutomaticGrant grants = ss.getCreateTableGrants();
        if (grants != null) {
          principalPrivs.setUserPrivileges(grants.getUserGrants());
          principalPrivs.setGroupPrivileges(grants.getGroupGrants());
          principalPrivs.setRolePrivileges(grants.getRoleGrants());
          tTbl.setPrivileges(principalPrivs);
        }
        if (AcidUtils.isTransactionalTable(tbl)) {
          boolean createTableUseSuffix = HiveConf.getBoolVar(conf, ConfVars.HIVE_ACID_CREATE_TABLE_USE_SUFFIX)
            || HiveConf.getBoolVar(conf, ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED);

          if (createTableUseSuffix 
                && (tbl.getSd().getLocation() == null || tbl.getSd().getLocation().isEmpty())) {
            tbl.setProperty(SOFT_DELETE_TABLE, Boolean.TRUE.toString());
          }
          tTbl.setTxnId(ss.getTxnMgr().getCurrentTxnId());
        }
      }
      // Set table snapshot to api.Table to make it persistent. A transactional table being
      // replicated may have a valid write Id copied from the source. Use that instead of
      // crafting one on the replica.
      if (tTbl.getWriteId() <= 0) {
        TableSnapshot tableSnapshot = AcidUtils.getTableSnapshot(conf, tbl, true);
        if (tableSnapshot != null) {
          tTbl.setWriteId(tableSnapshot.getWriteId());
        }
      }

      CreateTableRequest request = new CreateTableRequest(tTbl);

      if (isIcebergTable(tbl)) {
        EnvironmentContext envContext = new EnvironmentContext();
        if (TableType.MANAGED_TABLE.equals(tbl.getTableType())) {
          envContext.putToProperties(CTAS_LEGACY_CONFIG, Boolean.TRUE.toString());
        }
        if (isIcebergStatsSource(conf)) {
          envContext.putToProperties(StatsSetupConst.DO_NOT_UPDATE_STATS, StatsSetupConst.TRUE);
        }
        request.setEnvContext(envContext);
      }

      request.setPrimaryKeys(primaryKeys);
      request.setForeignKeys(foreignKeys);
      request.setUniqueConstraints(uniqueConstraints);
      request.setNotNullConstraints(notNullConstraints);
      request.setDefaultConstraints(defaultConstraints);
      request.setCheckConstraints(checkConstraints);

      getMSC().createTable(request);

    } catch (AlreadyExistsException e) {
      if (!ifNotExists) {
        throw new HiveException(e);
      }
    } catch (Exception e) {
      throw new HiveException(e);
    }
  }
Creates the table with the given objects. It takes additional arguments for
primary keys and foreign keys associated with the table.

@param tbl
         a table object
@param ifNotExists
         if true, ignore AlreadyExistsException
@param primaryKeys
         primary key columns associated with the table
@param foreignKeys
         foreign key columns associated with the table
@param uniqueConstraints
         UNIQUE constraints associated with the table
@param notNullConstraints
         NOT NULL constraints associated with the table
@param defaultConstraints
         DEFAULT constraints associated with the table
@param checkConstraints
         CHECK constraints associated with the table
@throws HiveException
ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java