private void createTable(SinkInfo sinkInfo) {
        LOGGER.info("begin to create hive table for sinkId={}", sinkInfo.getId());

        List<StreamSinkFieldEntity> fieldList = sinkFieldMapper.selectBySinkId(sinkInfo.getId());
        if (CollectionUtils.isEmpty(fieldList)) {
            LOGGER.warn("no hive fields found, skip to create table for sinkId={}", sinkInfo.getId());
        }

        // set columns
        List<HiveColumnInfo> columnList = new ArrayList<>();
        for (StreamSinkFieldEntity field : fieldList) {
            HiveColumnInfo columnInfo = new HiveColumnInfo();
            columnInfo.setName(field.getFieldName());
            columnInfo.setType(field.getFieldType());
            columnInfo.setDesc(field.getFieldComment());
            columnList.add(columnInfo);
        }

        try {
            HiveSinkDTO hiveInfo = this.getHiveInfo(sinkInfo);
            HiveTableInfo tableInfo = HiveSinkDTO.getHiveTableInfo(hiveInfo, columnList);
            String url = hiveInfo.getJdbcUrl();
            String user = hiveInfo.getUsername();
            String password = hiveInfo.getPassword();

            String dbName = tableInfo.getDbName();
            String tableName = tableInfo.getTableName();

            // 1. create database if not exists
            HiveJdbcUtils.createDb(url, user, password, dbName);

            // 2. check if the table exists
            List<String> tables = HiveJdbcUtils.getTables(url, user, password, dbName);
            boolean tableExists = tables.contains(tableName);

            // 3. table not exists, create it
            if (!tableExists) {
                HiveJdbcUtils.createTable(url, user, password, tableInfo);
            } else {
                // 4. table exists, add columns - skip the exists columns
                List<HiveColumnInfo> existColumns = HiveJdbcUtils.getColumns(url, user, password, dbName, tableName);
                List<HiveColumnInfo> needAddColumns = tableInfo.getColumns().stream()
                        .skip(existColumns.size()).collect(toList());
                if (CollectionUtils.isNotEmpty(needAddColumns)) {
                    HiveJdbcUtils.addColumns(url, user, password, dbName, tableName, needAddColumns);
                }
            }

            // 5. update the sink status to success
            String info = "success to create hive resource";
            sinkService.updateStatus(sinkInfo.getId(), SinkStatus.CONFIG_SUCCESSFUL.getCode(), info);
            LOGGER.info(info + " for sinkInfo={}", sinkInfo);
        } catch (Throwable e) {
            String errMsg = "create hive table failed: " + e.getMessage();
            LOGGER.error(errMsg, e);
            sinkService.updateStatus(sinkInfo.getId(), SinkStatus.CONFIG_FAILED.getCode(), errMsg);
            throw new WorkflowException(errMsg);
        }
    }
Create hive table according to the groupId and hive config
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/sink/hive/HiveResourceOperator.java