Skip to content

Commit

Permalink
[fix](mtmv)add logs for mv_infos() (apache#33485)
Browse files Browse the repository at this point in the history
  • Loading branch information
zddr authored Apr 11, 2024
1 parent 007e815 commit 47bb99f
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
19 changes: 19 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,4 +405,23 @@ public void readFields(DataInput in) throws IOException {
}
}

@Override
public String toString() {
return "MTMV{"
+ ", refreshInfo=" + refreshInfo
+ ", querySql='" + querySql + '\''
+ ", status=" + status
+ ", envInfo=" + envInfo
+ ", jobInfo=" + jobInfo
+ ", mvProperties=" + mvProperties
+ ", relation=" + relation
+ ", mvPartitionInfo=" + mvPartitionInfo
+ ", refreshSnapshot=" + refreshSnapshot
+ ", cache=" + cache
+ ", id=" + id
+ ", name='" + name + '\''
+ ", qualifiedDbName='" + qualifiedDbName + '\''
+ ", comment='" + comment + '\''
+ '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ public class MetadataGenerator {
}

public static TFetchSchemaTableDataResult getMetadataTable(TFetchSchemaTableDataRequest request) throws TException {
if (LOG.isDebugEnabled()) {
LOG.debug("getMetadataTable() start.");
}
if (!request.isSetMetadaTableParams() || !request.getMetadaTableParams().isSetMetadataType()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Metadata table params is not set.");
}
return errorResult("Metadata table params is not set. ");
}
TFetchSchemaTableDataResult result;
Expand Down Expand Up @@ -159,6 +165,9 @@ public static TFetchSchemaTableDataResult getMetadataTable(TFetchSchemaTableData
if (result.getStatus().getStatusCode() == TStatusCode.OK) {
filterColumns(result, params.getColumnsName(), params.getMetadataType(), params);
}
if (LOG.isDebugEnabled()) {
LOG.debug("getMetadataTable() end.");
}
return result;
}

Expand Down Expand Up @@ -613,6 +622,9 @@ private static List<TFetchSchemaTableDataResult> forwardToOtherFrontends(TFetchS

private static void filterColumns(TFetchSchemaTableDataResult result,
List<String> columnNames, TMetadataType type, TMetadataTableRequestParams params) throws TException {
if (LOG.isDebugEnabled()) {
LOG.debug("filterColumns() start.");
}
List<TRow> fullColumnsRow = result.getDataBatch();
List<TRow> filterColumnsRows = Lists.newArrayList();
for (TRow row : fullColumnsRow) {
Expand All @@ -628,6 +640,9 @@ private static void filterColumns(TFetchSchemaTableDataResult result,
filterColumnsRows.add(filterRow);
}
result.setDataBatch(filterColumnsRows);
if (LOG.isDebugEnabled()) {
LOG.debug("filterColumns() end.");
}
}

private static void filterColumns(TFetchSchemaTableDataResult result,
Expand Down Expand Up @@ -658,14 +673,26 @@ private static long convertToDateTimeV2(
}

private static TFetchSchemaTableDataResult mtmvMetadataResult(TMetadataTableRequestParams params) {
if (LOG.isDebugEnabled()) {
LOG.debug("mtmvMetadataResult() start");
}
if (!params.isSetMaterializedViewsMetadataParams()) {
if (LOG.isDebugEnabled()) {
LOG.debug("MaterializedViews metadata params is not set.");
}
return errorResult("MaterializedViews metadata params is not set.");
}

TMaterializedViewsMetadataParams mtmvMetadataParams = params.getMaterializedViewsMetadataParams();
String dbName = mtmvMetadataParams.getDatabase();
if (LOG.isDebugEnabled()) {
LOG.debug("dbName: " + dbName);
}
TUserIdentity currentUserIdent = mtmvMetadataParams.getCurrentUserIdent();
UserIdentity userIdentity = UserIdentity.fromThrift(currentUserIdent);
if (LOG.isDebugEnabled()) {
LOG.debug("userIdentity: " + userIdentity);
}
List<TRow> dataBatch = Lists.newArrayList();
TFetchSchemaTableDataResult result = new TFetchSchemaTableDataResult();
List<Table> tables;
Expand All @@ -674,6 +701,7 @@ private static TFetchSchemaTableDataResult mtmvMetadataResult(TMetadataTableRequ
.getCatalogOrAnalysisException(InternalCatalog.INTERNAL_CATALOG_NAME)
.getDbOrAnalysisException(dbName).getTables();
} catch (AnalysisException e) {
LOG.warn(e.getMessage());
return errorResult(e.getMessage());
}

Expand All @@ -686,6 +714,9 @@ private static TFetchSchemaTableDataResult mtmvMetadataResult(TMetadataTableRequ
continue;
}
MTMV mv = (MTMV) table;
if (LOG.isDebugEnabled()) {
LOG.debug("mv: " + mv);
}
TRow trow = new TRow();
trow.addToColumnValue(new TCell().setLongVal(mv.getId()));
trow.addToColumnValue(new TCell().setStringVal(mv.getName()));
Expand All @@ -699,11 +730,17 @@ private static TFetchSchemaTableDataResult mtmvMetadataResult(TMetadataTableRequ
trow.addToColumnValue(new TCell().setStringVal(mv.getMvProperties().toString()));
trow.addToColumnValue(new TCell().setStringVal(mv.getMvPartitionInfo().toNameString()));
trow.addToColumnValue(new TCell().setBoolVal(MTMVPartitionUtil.isMTMVSync(mv)));
if (LOG.isDebugEnabled()) {
LOG.debug("mvend: " + mv.getName());
}
dataBatch.add(trow);
}
}
result.setDataBatch(dataBatch);
result.setStatus(new TStatus(TStatusCode.OK));
if (LOG.isDebugEnabled()) {
LOG.debug("mtmvMetadataResult() end");
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;
import java.util.Map;
Expand All @@ -39,6 +41,8 @@
* mv_infos("database" = "db1").
*/
public class MvInfosTableValuedFunction extends MetadataTableValuedFunction {
private static final Logger LOG = LogManager.getLogger(MvInfosTableValuedFunction.class);

public static final String NAME = "mv_infos";
private static final String DB = "database";

Expand Down Expand Up @@ -75,6 +79,9 @@ public static Integer getColumnIndexFromColumnName(String columnName) {
private final String databaseName;

public MvInfosTableValuedFunction(Map<String, String> params) throws AnalysisException {
if (LOG.isDebugEnabled()) {
LOG.debug("MvInfosTableValuedFunction() start");
}
Map<String, String> validParams = Maps.newHashMap();
for (String key : params.keySet()) {
if (!PROPERTIES_SET.contains(key.toLowerCase())) {
Expand All @@ -88,6 +95,9 @@ public MvInfosTableValuedFunction(Map<String, String> params) throws AnalysisExc
throw new AnalysisException("Invalid mtmv metadata query");
}
this.databaseName = dbName;
if (LOG.isDebugEnabled()) {
LOG.debug("MvInfosTableValuedFunction() end");
}
}

@Override
Expand All @@ -97,12 +107,18 @@ public TMetadataType getMetadataType() {

@Override
public TMetaScanRange getMetaScanRange() {
if (LOG.isDebugEnabled()) {
LOG.debug("getMetaScanRange() start");
}
TMetaScanRange metaScanRange = new TMetaScanRange();
metaScanRange.setMetadataType(TMetadataType.MATERIALIZED_VIEWS);
TMaterializedViewsMetadataParams mtmvParam = new TMaterializedViewsMetadataParams();
mtmvParam.setDatabase(databaseName);
mtmvParam.setCurrentUserIdent(ConnectContext.get().getCurrentUserIdentity().toThrift());
metaScanRange.setMaterializedViewsParams(mtmvParam);
if (LOG.isDebugEnabled()) {
LOG.debug("getMetaScanRange() end");
}
return metaScanRange;
}

Expand Down

0 comments on commit 47bb99f

Please sign in to comment.