public void createTableLike(CreateTableLikeStmt stmt) throws DdlException {
        String catalogName = stmt.getCatalogName();
        Optional<ConnectorMetadata> connectorMetadata = getOptionalMetadata(catalogName);

        if (connectorMetadata.isPresent()) {
            String dbName = stmt.getDbName();
            String tableName = stmt.getTableName();
            if (tableExists(catalogName, dbName, tableName)) {
                if (stmt.isSetIfNotExists()) {
                    LOG.info("create table[{}] which already exists", tableName);
                    return;
                } else {
                    ErrorReport.reportDdlException(ErrorCode.ERR_TABLE_EXISTS_ERROR, tableName);
                }
            }
            connectorMetadata.get().createTableLike(stmt);
        } else {
            throw new DdlException("Invalid catalog " + catalogName + " , ConnectorMetadata doesn't exist");
        }
    }
@Test
    public void testHiveCreateTableLike() throws Exception {
        class MockedHiveMetadataMgr extends MockedMetadataMgr {

            public MockedHiveMetadataMgr(LocalMetastore localMetastore, ConnectorMgr connectorMgr) {
                super(localMetastore, connectorMgr);
            }

            @Override
            public com.starrocks.catalog.Database getDb(String catalogName, String dbName) {
                return new com.starrocks.catalog.Database(0, "hive_db", "s3://test-db/");
            }

            @Override
            public com.starrocks.catalog.Table getTable(String catalogName, String dbName, String tblName) {
                List<FieldSchema> partKeys = Lists.newArrayList(new FieldSchema("col1", "INT", ""));
                List<FieldSchema> unPartKeys = Lists.newArrayList(new FieldSchema("col2", "INT", ""));
                String hdfsPath = "hdfs://127.0.0.1:10000/hive";
                StorageDescriptor sd = new StorageDescriptor();
                sd.setInputFormat(MAPRED_PARQUET_INPUT_FORMAT_CLASS);
                sd.setCols(unPartKeys);
                sd.setLocation(hdfsPath);
                Table msTable = new Table();
                msTable.setPartitionKeys(partKeys);
                msTable.setSd(sd);
                msTable.setTableType("MANAGED_TABLE");
                msTable.setTableName("hive_tbl");
                msTable.setDbName("hive_db");
                int createTime = (int) System.currentTimeMillis();
                msTable.setCreateTime(createTime);

                return HiveMetastoreApiConverter.toHiveTable(msTable, "hive_catalog");
            }

            @Override
            public boolean tableExists(String catalogName, String dbName, String tblName) {
                return (catalogName.equals("hive_catalog") && dbName.equals("hive_db") && tblName.equals("hive_tbl")) ||
                        (catalogName.equals("hive_catalog") && dbName.equals("hive_db") && tblName.equals("hive_tbl_1"));
            }
        }

        ConnectContext connectContext = AnalyzeTestUtil.getConnectContext();
        MetadataMgr metadataMgr = GlobalStateMgr.getCurrentState().getMetadataMgr();
        MockedHiveMetadataMgr mockedHiveMetadataMgr = new MockedHiveMetadataMgr(
                connectContext.getGlobalStateMgr().getLocalMetastore(),
                connectContext.getGlobalStateMgr().getConnectorMgr());

        // set to mockedHiveMetadataMgr to pass Analyzer check
        GlobalStateMgr.getCurrentState().setMetadataMgr(mockedHiveMetadataMgr);
        MockedHiveMetadata mockedHiveMetadata = new MockedHiveMetadata();
        mockedHiveMetadataMgr.registerMockedMetadata("hive_catalog", mockedHiveMetadata);

        String stmt = "create external table hive_catalog_1.hive_db.hive_tbl_1 like hive_catalog.hive_db.hive_tbl";
        CreateTableLikeStmt createTableLikeStmt =
                (CreateTableLikeStmt) UtFrameUtils.parseStmtWithNewParser(stmt, AnalyzeTestUtil.getConnectContext());

        try {
            mockedHiveMetadataMgr.createTableLike(createTableLikeStmt);
        } catch (Exception e) {
            Assert.assertTrue(e instanceof DdlException);
            Assert.assertTrue(e.getMessage().contains("Invalid catalog hive_catalog_1"));
        }

        stmt = "create external table hive_catalog.hive_db.hive_tbl_1 like hive_catalog.hive_db.hive_table";
        createTableLikeStmt =
                (CreateTableLikeStmt) UtFrameUtils.parseStmtWithNewParser(stmt, AnalyzeTestUtil.getConnectContext());

        try {
            mockedHiveMetadataMgr.createTableLike(createTableLikeStmt);
        } catch (Exception e) {
            Assert.assertTrue(e instanceof DdlException);
            Assert.assertTrue(e.getMessage().contains("Table 'hive_tbl_1' already exists"));
        }

        stmt = "create external table hive_catalog.hive_db.hive_tbl_2 like hive_catalog.hive_db.hive_tbl";
        createTableLikeStmt =
                (CreateTableLikeStmt) UtFrameUtils.parseStmtWithNewParser(stmt, AnalyzeTestUtil.getConnectContext());

        try {
            mockedHiveMetadataMgr.createTableLike(createTableLikeStmt);
        } catch (Exception e) {
            Assert.assertNull(e);
        }

        stmt = "create external table if not exists hive_catalog.hive_db.hive_tbl_1 like hive_catalog.hive_db.hive_table";
        createTableLikeStmt =
                (CreateTableLikeStmt) UtFrameUtils.parseStmtWithNewParser(stmt, AnalyzeTestUtil.getConnectContext());

        try {
            mockedHiveMetadataMgr.createTableLike(createTableLikeStmt);
        } catch (Exception e) {
            Assert.assertNull(e);
        }

        stmt = "create external table if not exists hive_catalog.hive_db.hive_tbl_2 like hive_catalog.hive_db.hive_table";
        createTableLikeStmt =
                (CreateTableLikeStmt) UtFrameUtils.parseStmtWithNewParser(stmt, AnalyzeTestUtil.getConnectContext());

        try {
            mockedHiveMetadataMgr.createTableLike(createTableLikeStmt);
        } catch (Exception e) {
            Assert.assertNull(e);
        }

        // set back to original metadataMrg
        GlobalStateMgr.getCurrentState().setMetadataMgr(metadataMgr);
    }