public RuntimeProfile buildTopLevelProfile(boolean isFinished) {
        RuntimeProfile profile = new RuntimeProfile("Load");
        RuntimeProfile summaryProfile = new RuntimeProfile("Summary");
        summaryProfile.addInfoString(ProfileManager.QUERY_ID, DebugUtil.printId(getLoadId()));
        summaryProfile.addInfoString(ProfileManager.START_TIME,
                TimeUtils.longToTimeString(createTimestamp));

        long currentTimestamp = System.currentTimeMillis();
        long totalTimeMs = currentTimestamp - createTimestamp;
        summaryProfile.addInfoString(ProfileManager.END_TIME, TimeUtils.longToTimeString(currentTimestamp));
        summaryProfile.addInfoString(ProfileManager.TOTAL_TIME, DebugUtil.getPrettyStringMs(totalTimeMs));

        summaryProfile.addInfoString(ProfileManager.QUERY_TYPE, "Load");
        summaryProfile.addInfoString(ProfileManager.QUERY_STATE, isFinished ? "Finished" : "Running");
        summaryProfile.addInfoString("StarRocks Version",
                String.format("%s-%s", Version.STARROCKS_VERSION, Version.STARROCKS_COMMIT_HASH));
        summaryProfile.addInfoString(ProfileManager.USER, context.getQualifiedUser());
        summaryProfile.addInfoString(ProfileManager.DEFAULT_DB, context.getDatabase());
        summaryProfile.addInfoString(ProfileManager.SQL_STATEMENT, originStmt.originStmt);
        summaryProfile.addInfoString("Timeout", DebugUtil.getPrettyStringMs(timeoutS * 1000));
        summaryProfile.addInfoString("Strict Mode", String.valueOf(strictMode));
        summaryProfile.addInfoString("Partial Update", String.valueOf(partialUpdate));

        SessionVariable variables = context.getSessionVariable();
        if (variables != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("load_parallel_instance_num=").append(Config.load_parallel_instance_num).append(",");
            sb.append(SessionVariable.PARALLEL_FRAGMENT_EXEC_INSTANCE_NUM).append("=")
                    .append(variables.getParallelExecInstanceNum()).append(",");
            sb.append(SessionVariable.MAX_PARALLEL_SCAN_INSTANCE_NUM).append("=")
                    .append(variables.getMaxParallelScanInstanceNum()).append(",");
            sb.append(SessionVariable.PIPELINE_DOP).append("=").append(variables.getPipelineDop()).append(",");
            sb.append(SessionVariable.ENABLE_ADAPTIVE_SINK_DOP).append("=")
                    .append(variables.getEnableAdaptiveSinkDop())
                    .append(",");
            if (context.getResourceGroup() != null) {
                sb.append(SessionVariable.RESOURCE_GROUP).append("=")
                        .append(context.getResourceGroup().getName())
                        .append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            summaryProfile.addInfoString(ProfileManager.VARIABLES, sb.toString());

            summaryProfile.addInfoString("NonDefaultSessionVariables", variables.getNonDefaultVariablesJson());
        }

        profile.addChild(summaryProfile);

        return profile;
    }
@Test
    public void testBuildTopLevelProfile(@Mocked GlobalStateMgr globalStateMgr,
                                          @Mocked GlobalTransactionMgr globalTransactionMgr,
                                          @Mocked TransactionState transactionState) {
        new Expectations() {
            {
                GlobalStateMgr.getCurrentState().getNextId();
                result = 1;
                connectContext.getSessionVariable();
                result = new SessionVariable();
                connectContext.getQualifiedUser();
                result = "test_user";
                connectContext.getDatabase();
                result = "test_db";

                GlobalStateMgr.getCurrentState();
                result = globalStateMgr;
            }
        };

        // Call the method under test
        Database database = new Database(10000L, "test");
        OlapTable olapTable = new OlapTable(10001L, "tbl", null, KeysType.AGG_KEYS, null, null);
        LoadLoadingTask loadLoadingTask = new LoadLoadingTask.Builder().setDb(database)
                .setTable(olapTable).setContext(connectContext).setOriginStmt(new OriginStatement("")).build();
        RuntimeProfile profile = loadLoadingTask.buildRunningTopLevelProfile();
        // Perform assertions to verify the behavior
        assertNotNull("Profile should not be null", profile);

        profile = loadLoadingTask.buildFinishedTopLevelProfile();
        // Perform assertions to verify the behavior
        assertNotNull("Profile should not be null", profile);
    }