gavinchou commented on code in PR #34384: URL: https://github.com/apache/doris/pull/34384#discussion_r1604463773
########## fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java: ########## @@ -873,4 +892,75 @@ private static TFetchSchemaTableDataResult routineInfoMetadataResult(TSchemaTabl result.setStatus(new TStatus(TStatusCode.OK)); return result; } + + private static TFetchSchemaTableDataResult tableOptionsMetadataResult(TSchemaTableRequestParams params) { + if (!params.isSetCurrentUserIdent()) { + return errorResult("current user ident is not set."); + } + + TFetchSchemaTableDataResult result = new TFetchSchemaTableDataResult(); + List<TRow> dataBatch = Lists.newArrayList(); + List<Long> catalogIds = Env.getCurrentEnv().getCatalogMgr().getCatalogIds(); + for (Long catalogId : catalogIds) { + CatalogIf catalog = Env.getCurrentEnv().getCatalogMgr().getCatalog(catalogId); + List<Long> dbIds = catalog.getDbIds(); + for (Long dbId : dbIds) { + DatabaseIf database = catalog.getDbNullable(dbId); + List<TableIf> tables = database.getTables(); + for (TableIf table : tables) { + if (table instanceof OlapTable) { + OlapTable olapTable = (OlapTable) table; + TRow trow = new TRow(); + trow.addToColumnValue(new TCell().setStringVal(table.getName())); // TABLE_NAME + trow.addToColumnValue(new TCell().setStringVal(catalog.getName())); // TABLE_CATALOG + trow.addToColumnValue(new TCell().setStringVal(database.getFullName())); // TABLE_SCHEMA + trow.addToColumnValue( + new TCell().setStringVal(olapTable.getKeysType().toMetadata())); //TABLE_MODEL + trow.addToColumnValue( + new TCell().setStringVal(olapTable.getKeyColAsString())); // key columTypes + + DistributionInfo distributionInfo = olapTable.getDefaultDistributionInfo(); + if (distributionInfo.getType() == DistributionInfoType.HASH) { + HashDistributionInfo hashDistributionInfo = (HashDistributionInfo) distributionInfo; + List<Column> distributionColumns = hashDistributionInfo.getDistributionColumns(); + StringBuilder distributeKey = new StringBuilder(); + for (Column c : distributionColumns) { + if (distributeKey.length() != 0) { + distributeKey.append(","); + } + distributeKey.append(c.getName()); + } + if (distributeKey.length() == 0) { + trow.addToColumnValue(new TCell().setStringVal("")); + } else { + trow.addToColumnValue( + new TCell().setStringVal(distributeKey.toString())); + } + trow.addToColumnValue(new TCell().setStringVal("HASH")); // DISTRIBUTE_TYPE + } else { + trow.addToColumnValue(new TCell().setStringVal("RANDOM")); // DISTRIBUTE_KEY + trow.addToColumnValue(new TCell().setStringVal("RANDOM")); // DISTRIBUTE_TYPE + } + trow.addToColumnValue(new TCell().setIntVal(distributionInfo.getBucketNum())); // BUCKETS_NUM + trow.addToColumnValue(new TCell().setIntVal(olapTable.getPartitionNum())); // PARTITION_NUM + TableProperty property = olapTable.getTableProperty(); + if (property == null) { + trow.addToColumnValue(new TCell().setStringVal("")); // PROPERTIES + } else { + try { + trow.addToColumnValue( + new TCell().setStringVal(property.getPropertiesString())); // PROPERTIES + } catch (IOException e) { + return errorResult(e.getMessage()); + } + } + dataBatch.add(trow); + } + } + } + } Review Comment: ```suggestion } // if instance of } // for table } // for db } // for catalog ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org