@Override
    public ProcResult fetchResult() throws AnalysisException {
        Preconditions.checkNotNull(db);

        // get info
        List<List<Comparable>> tableInfos = new ArrayList<List<Comparable>>();
        Locker locker = new Locker();
        locker.lockDatabase(db, LockType.READ);
        try {
            for (Table table : db.getTables()) {
                List<Comparable> tableInfo = new ArrayList<Comparable>();
                TableType tableType = table.getType();
                tableInfo.add(table.getId());
                tableInfo.add(table.getName());
                tableInfo.add(findIndexNum(table));
                tableInfo.add(findPartitionKey(table));
                tableInfo.add(findPartitionNum(table));
                tableInfo.add(findState(table));
                tableInfo.add(tableType);
                tableInfo.add(TimeUtils.longToTimeString(table.getLastCheckTime()));
                tableInfo.add(findReplicaCount(table));
                tableInfo.add(findPartitionType(table));
                tableInfo.add(findStoragePath(table));
                tableInfos.add(tableInfo);
            }
        } finally {
            locker.unLockDatabase(db, LockType.READ);
        }

        // sort by table id
        ListComparator<List<Comparable>> comparator = new ListComparator<List<Comparable>>(0);
        Collections.sort(tableInfos, comparator);

        // set result
        BaseProcResult result = new BaseProcResult();
        result.setNames(TITLE_NAMES);

        for (List<Comparable> info : tableInfos) {
            List<String> row = new ArrayList<String>(info.size());
            for (Comparable comparable : info) {
                row.add(comparable.toString());
            }
            result.addRow(row);
        }

        return result;
    }
@Test
    public void testFetchResult() throws AnalysisException {
        BaseProcResult result = (BaseProcResult) new TablesProcDir(db).fetchResult();
        List<List<String>> rows = result.getRows();
        List<String> list1 = rows.get(0);
        Assert.assertEquals(list1.size(), TablesProcDir.TITLE_NAMES.size());
        // TableId
        Assert.assertEquals("1000", list1.get(0));
        // TableName
        Assert.assertEquals("tb1", list1.get(1));
        // IndexNum
        Assert.assertEquals("1", list1.get(2));
        // PartitionColumnName
        Assert.assertEquals("province", list1.get(3));
        // PartitionNum
        Assert.assertEquals("1", list1.get(4));
        // State
        Assert.assertEquals("NORMAL", list1.get(5));
        // Type
        Assert.assertEquals("OLAP", list1.get(6));
        // LastConsistencyCheckTime
        Assert.assertEquals(FeConstants.NULL_STRING, list1.get(7));
        // ReplicaCount
        Assert.assertEquals("2", list1.get(8));
        // PartitionType
        Assert.assertEquals("LIST", list1.get(9));

        List<String> list2 = rows.get(1);
        Assert.assertEquals(list2.size(), TablesProcDir.TITLE_NAMES.size());
        // TableId
        Assert.assertEquals("2000", list2.get(0));
        // TableName
        Assert.assertEquals("tb2", list2.get(1));
        // IndexNum
        Assert.assertEquals("1", list2.get(2));
        // PartitionColumnName
        Assert.assertEquals("dt", list2.get(3));
        // PartitionNum
        Assert.assertEquals("1", list2.get(4));
        // State
        Assert.assertEquals("NORMAL", list2.get(5));
        // Type
        Assert.assertEquals("OLAP", list2.get(6));
        // LastConsistencyCheckTime
        Assert.assertEquals(FeConstants.NULL_STRING, list2.get(7));
        // ReplicaCount
        Assert.assertEquals("2", list2.get(8));
        // PartitionType
        Assert.assertEquals("RANGE", list2.get(9));

        List<String> list3 = rows.get(2);
        Assert.assertEquals(list2.size(), TablesProcDir.TITLE_NAMES.size());
        // TableId
        Assert.assertEquals("3000", list3.get(0));
        // TableName
        Assert.assertEquals("tb3", list3.get(1));
        // IndexNum
        Assert.assertEquals(FeConstants.NULL_STRING, list3.get(2));
        // PartitionColumnName
        Assert.assertEquals(FeConstants.NULL_STRING, list3.get(3));
        // PartitionNum
        Assert.assertEquals("1", list3.get(4));
        // State
        Assert.assertEquals(FeConstants.NULL_STRING, list3.get(5));
        // Type
        Assert.assertEquals("HUDI", list3.get(6));
        // LastConsistencyCheckTime
        Assert.assertEquals(FeConstants.NULL_STRING, list3.get(7));
        // ReplicaCount
        Assert.assertEquals("0", list3.get(8));
        // PartitionType
        Assert.assertEquals("UNPARTITIONED", list3.get(9));

    }