Support analyze rollup. (#31576)
This commit is contained in:
@ -495,12 +495,18 @@ public class OlapTable extends Table implements MTMVRelatedTableIf {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is for statistics collection only. To get all the index ids that contains the given columnName.
|
||||
* For base index, return -1 as its id, this is for compatibility with older version of column stats.
|
||||
* @param columnName
|
||||
* @return index id list that contains the given columnName.
|
||||
*/
|
||||
public List<Long> getMvColumnIndexIds(String columnName) {
|
||||
List<Long> ids = Lists.newArrayList();
|
||||
for (MaterializedIndexMeta meta : getVisibleIndexIdToMeta().values()) {
|
||||
Column target = meta.getColumnByDefineName(columnName);
|
||||
if (target != null) {
|
||||
ids.add(meta.getIndexId());
|
||||
ids.add(meta.getIndexId() == baseIndexId ? -1 : meta.getIndexId());
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
|
||||
@ -2597,9 +2597,8 @@ public class ShowExecutor {
|
||||
for (String colName : columnNames) {
|
||||
// Olap base index use -1 as index id.
|
||||
List<Long> indexIds = Lists.newArrayList();
|
||||
if (StatisticsUtil.isMvColumn(tableIf, colName)) {
|
||||
OlapTable olapTable = (OlapTable) tableIf;
|
||||
indexIds = olapTable.getMvColumnIndexIds(colName);
|
||||
if (tableIf instanceof OlapTable) {
|
||||
indexIds = ((OlapTable) tableIf).getMvColumnIndexIds(colName);
|
||||
} else {
|
||||
indexIds.add(-1L);
|
||||
}
|
||||
@ -3026,7 +3025,7 @@ public class ShowExecutor {
|
||||
List<String> row = new ArrayList<>();
|
||||
row.add(String.valueOf(analysisInfo.taskId));
|
||||
row.add(analysisInfo.colName);
|
||||
if (StatisticsUtil.isMvColumn(table, analysisInfo.colName)) {
|
||||
if (table instanceof OlapTable && analysisInfo.indexId != -1) {
|
||||
row.add(((OlapTable) table).getIndexNameById(analysisInfo.indexId));
|
||||
} else {
|
||||
row.add("N/A");
|
||||
|
||||
@ -423,9 +423,8 @@ public class AnalysisManager implements Writable {
|
||||
String colName = entry.getKey();
|
||||
List<Long> indexIds = Lists.newArrayList();
|
||||
// Get index id this column belongs to for OlapTable. Set it to -1 for baseIndex id.
|
||||
if (StatisticsUtil.isMvColumn(table, colName)) {
|
||||
OlapTable olapTable = (OlapTable) table;
|
||||
indexIds = olapTable.getMvColumnIndexIds(colName);
|
||||
if (table instanceof OlapTable) {
|
||||
indexIds = ((OlapTable) table).getMvColumnIndexIds(colName);
|
||||
} else {
|
||||
indexIds.add(-1L);
|
||||
}
|
||||
@ -702,9 +701,8 @@ public class AnalysisManager implements Writable {
|
||||
|
||||
for (String column : columns) {
|
||||
List<Long> indexIds = Lists.newArrayList();
|
||||
if (StatisticsUtil.isMvColumn(table, column)) {
|
||||
OlapTable olapTable = (OlapTable) table;
|
||||
indexIds = olapTable.getMvColumnIndexIds(column);
|
||||
if (table instanceof OlapTable) {
|
||||
indexIds = ((OlapTable) table).getMvColumnIndexIds(column);
|
||||
} else {
|
||||
indexIds.add(-1L);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user