public static TObjectDependencyRes listObjectDependencies(TObjectDependencyReq req) {
        TAuthInfo auth = req.getAuth_info();
        TObjectDependencyRes response = new TObjectDependencyRes();

        UserIdentity currentUser;
        if (auth.isSetCurrent_user_ident()) {
            currentUser = UserIdentity.fromThrift(auth.getCurrent_user_ident());
        } else {
            currentUser = UserIdentity.createAnalyzedUserIdentWithIp(auth.getUser(), auth.getUser_ip());
        }

        // list dependencies of mv
        Locker locker = new Locker();
        Collection<Database> dbs = GlobalStateMgr.getCurrentState().getLocalMetastore().getFullNameToDb().values();
        for (Database db : CollectionUtils.emptyIfNull(dbs)) {
            String catalog = Optional.ofNullable(db.getCatalogName())
                    .orElse(InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME);
            locker.lockDatabase(db, LockType.READ);
            try {
                for (Table table : db.getTables()) {
                    // If it is not a materialized view, we do not need to verify permissions
                    if (!table.isMaterializedView()) {
                        continue;
                    }
                    // Only show tables with privilege
                    try {
                        Authorizer.checkAnyActionOnTableLikeObject(currentUser, null, db.getFullName(), table);
                    } catch (AccessDeniedException e) {
                        continue;
                    }

                    MaterializedView mv = (MaterializedView) table;
                    for (BaseTableInfo refObj : CollectionUtils.emptyIfNull(mv.getBaseTableInfos())) {
                        TObjectDependencyItem item = new TObjectDependencyItem();
                        item.setObject_id(mv.getId());
                        item.setObject_name(mv.getName());
                        item.setDatabase(db.getFullName());
                        item.setCatalog(catalog);
                        item.setObject_type(mv.getType().toString());

                        item.setRef_object_id(refObj.getTableId());
                        item.setRef_database(refObj.getDbName());
                        item.setRef_catalog(refObj.getCatalogName());
                        Optional<Table> refTable = MvUtils.getTableWithIdentifier(refObj);
                        item.setRef_object_type(getRefObjectType(refTable, mv.getName()));
                        // If the ref table is dropped/swapped/renamed, the actual info would be inconsistent with
                        // BaseTableInfo, so we use the source-of-truth information
                        if (refTable.isEmpty()) {
                            item.setRef_object_name(refObj.getTableName());
                        } else {
                            item.setRef_object_name(refTable.get().getName());
                        }

                        response.addToItems(item);
                    }
                }
            } finally {
                locker.unLockDatabase(db, LockType.READ);
            }
        }

        return response;
    }
@Test
    public void testObjectDependencies() throws Exception {
        starRocksAssert.withTable("CREATE TABLE test.test_mv_base_table\n" +
                        "(\n" + "    k1 date,\n" + "    k2 int,\n" + "    v1 int sum\n" + ")\n"
                        + "PARTITION BY RANGE(k1)\n" +
                        "(\n" + "    PARTITION p1 values [('2022-02-01'),('2022-02-16')),\n"
                        + "    PARTITION p2 values [('2022-02-16'),('2022-03-01'))\n" + ")\n"
                        + "DISTRIBUTED BY HASH(k2) BUCKETS 3\n" + "PROPERTIES('replication_num' = '1');")
                .withMaterializedView("create materialized view test.mv_1\n"
                        + "PARTITION BY k1\n" + "distributed by hash(k2) buckets 3\n"
                        + "refresh async\n"
                        + "as select k1, k2, sum(v1) as total from test_mv_base_table group by k1, k2;")
                .withMaterializedView("create materialized view test.mv_2\n"
                        + "PARTITION BY date_trunc('month', k1)\n"
                        + "distributed by hash(k2) buckets 3\n"
                        + "refresh async\n"
                        + "as select k1, k2, sum(v1) as total from test_mv_base_table group by k1, k2;");


        String grantSql2 = "GRANT ALL ON TABLE test.test_mv_base_table TO USER `test_mv`@`%`;";
        String grantSql = "GRANT ALL ON MATERIALIZED VIEW test.mv_1 TO USER `test_mv`@`%`;";
        String grantSql1 = "GRANT ALL ON MATERIALIZED VIEW test.mv_2 TO USER `test_mv`@`%`;";
        DDLStmtExecutor.execute(UtFrameUtils.parseStmtWithNewParser(grantSql2, connectContext), connectContext);
        DDLStmtExecutor.execute(UtFrameUtils.parseStmtWithNewParser(grantSql, connectContext), connectContext);
        DDLStmtExecutor.execute(UtFrameUtils.parseStmtWithNewParser(grantSql1, connectContext), connectContext);

        TObjectDependencyReq dependencyReq = buildRequest();

        TObjectDependencyRes objectDependencyRes = SysObjectDependencies.listObjectDependencies(dependencyReq);
        Assert.assertNotNull(objectDependencyRes);
        Assert.assertEquals(2, objectDependencyRes.getItemsSize());
        Assert.assertEquals("OLAP", objectDependencyRes.getItems().get(0).getRef_object_type());
    }