private void addPartition(AlterTableStmt stmt, AlterClause alterClause) {
        HiveTable table = (HiveTable) getTable(stmt.getDbName(), stmt.getTableName());
        AddPartitionClause addPartitionClause = (AddPartitionClause) alterClause;
        List<String> partitionColumns = table.getPartitionColumnNames();
        // now do not support to specify location of hive partition in add partition
        if (!(addPartitionClause.getPartitionDesc() instanceof SingleItemListPartitionDesc)) {
            return;
        }
        SingleItemListPartitionDesc partitionDesc = (SingleItemListPartitionDesc) addPartitionClause.getPartitionDesc();
        String tablePath = table.getTableLocation();
        String partitionString = partitionColumns.get(0) + "=" + partitionDesc.getValues().get(0);
        String partitionPath = tablePath + "/" + partitionString;
        HivePartition hivePartition = HivePartition.builder()
                .setDatabaseName(table.getDbName())
                .setTableName(table.getTableName())
                .setColumns(table.getDataColumnNames().stream()
                        .map(table::getColumn)
                        .collect(Collectors.toList()))
                .setValues(partitionDesc.getValues())
                .setParameters(ImmutableMap.<String, String>builder()
                        .put("starrocks_version", Version.STARROCKS_VERSION + "-" + Version.STARROCKS_COMMIT_HASH)
                        .put(STARROCKS_QUERY_ID, ConnectContext.get().getQueryId().toString())
                        .buildOrThrow())
                .setStorageFormat(table.getStorageFormat())
                .setLocation(partitionPath)
                .build();
        HivePartitionWithStats partitionWithStats =
                new HivePartitionWithStats(partitionString, hivePartition, HivePartitionStats.empty());
        hmsOps.addPartitions(table.getDbName(), table.getTableName(), Lists.newArrayList(partitionWithStats));
    }
@Test(expected = StarRocksConnectorException.class)
    public void testAddPartition() throws Exception {
        String stagingDir = "hdfs://127.0.0.1:10000/tmp/starrocks/queryid";
        THiveFileInfo fileInfo = new THiveFileInfo();
        fileInfo.setFile_name("myfile.parquet");
        fileInfo.setPartition_path("hdfs://127.0.0.1:10000/tmp/starrocks/queryid/col1=2");
        fileInfo.setRecord_count(10);
        fileInfo.setFile_size_in_bytes(100);
        TSinkCommitInfo tSinkCommitInfo = new TSinkCommitInfo();
        tSinkCommitInfo.setStaging_dir(stagingDir);
        tSinkCommitInfo.setIs_overwrite(false);
        tSinkCommitInfo.setHive_file_info(fileInfo);

        new MockUp<HiveMetastoreOperations>() {
            @Mock
            public boolean partitionExists(String dbName, String tableName, List<String> partitionValues) {
                return false;
            }
        };

        new MockUp<RemoteFileOperations>() {
            @Mock
            public void renameDirectory(Path source, Path target, Runnable runWhenPathNotExist) {
            }
        };

        AnalyzeTestUtil.init();
        hiveMetadata.finishSink("hive_db", "hive_table", Lists.newArrayList(tSinkCommitInfo), null);

        new MockUp<HiveMetastoreOperations>() {
            @Mock
            public void addPartitions(String dbName, String tableName, List<HivePartitionWithStats> partitions) {
                throw new StarRocksConnectorException("add partition failed");
            }
        };
        hiveMetadata.finishSink("hive_db", "hive_table", Lists.newArrayList(tSinkCommitInfo), null);
    }