EmmyMiao87 commented on a change in pull request #3677:
URL: https://github.com/apache/incubator-doris/pull/3677#discussion_r436593235
##########
File path: fe/src/main/java/org/apache/doris/analysis/InsertStmt.java
##########
@@ -453,6 +453,26 @@ private void analyzeSubquery(Analyzer analyzer) throws
UserException {
}
}
+ //Get the correspondence of this column to the original column through
defineExpr
+ Map<Integer, Integer> origColIdx2MvColIdx = Maps.newHashMap();
+ for (int mvColumnIdx = 0; mvColumnIdx <
targetTable.getFullSchema().size(); ++mvColumnIdx) {
+ Column column = targetTable.getFullSchema().get(mvColumnIdx);
+ if
(column.isNameWithPrefix(CreateMaterializedViewStmt.MATERIALIZED_VIEW_NAME_PRFIX))
{
+ List<Expr> slots = new ArrayList<>();
+ column.getDefineExpr().collect(SlotRef.class, slots);
Review comment:
Please abstract function name `getRefColumn` in Column
##########
File path: fe/src/main/java/org/apache/doris/analysis/InsertStmt.java
##########
@@ -453,6 +453,26 @@ private void analyzeSubquery(Analyzer analyzer) throws
UserException {
}
}
+ //Get the correspondence of this column to the original column through
defineExpr
+ Map<Integer, Integer> origColIdx2MvColIdx = Maps.newHashMap();
Review comment:
Do not use the index of origin col. The `fullSchema` may be rebuilt and
the index of origin col may be changed.
##########
File path: fe/src/main/java/org/apache/doris/analysis/InsertStmt.java
##########
@@ -453,6 +453,26 @@ private void analyzeSubquery(Analyzer analyzer) throws
UserException {
}
}
+ //Get the correspondence of this column to the original column through
defineExpr
+ Map<Integer, Integer> origColIdx2MvColIdx = Maps.newHashMap();
+ for (int mvColumnIdx = 0; mvColumnIdx <
targetTable.getFullSchema().size(); ++mvColumnIdx) {
+ Column column = targetTable.getFullSchema().get(mvColumnIdx);
+ if
(column.isNameWithPrefix(CreateMaterializedViewStmt.MATERIALIZED_VIEW_NAME_PRFIX))
{
+ List<Expr> slots = new ArrayList<>();
+ column.getDefineExpr().collect(SlotRef.class, slots);
+ //We only support one children of define expr in materialized
view column
+ Preconditions.checkArgument(slots.size() == 1);
+ String origName = ((SlotRef) slots.get(0)).getColumnName();
+ for (int originColumnIdx = 0; originColumnIdx <
targetColumns.size(); originColumnIdx++) {
+ if
(targetColumns.get(originColumnIdx).nameEquals(origName, false)) {
+ origColIdx2MvColIdx.put(mvColumnIdx, originColumnIdx);
Review comment:
mvColumnIdxToOrigColumnIdx?
##########
File path: fe/src/main/java/org/apache/doris/analysis/InsertStmt.java
##########
@@ -519,17 +556,23 @@ private void analyzeSubquery(Analyzer analyzer) throws
UserException {
}
// expand baseTblResultExprs and colLabels in QueryStmt
- if (!origColIdxsForShadowCols.isEmpty()) {
+ if (!origColIdxsForShadowCols.isEmpty() ||
!origColIdx2MvColIdx.isEmpty()) {
if (queryStmt.getResultExprs().size() !=
queryStmt.getBaseTblResultExprs().size()) {
for (Integer idx : origColIdxsForShadowCols) {
queryStmt.getBaseTblResultExprs().add(queryStmt.getBaseTblResultExprs().get(idx));
}
+ for (Integer idx : origColIdx2MvColIdx.keySet()) {
Review comment:
The key of origColIdx2MvColIdx is mvColIdx. The mvColumn has been
supplied at the end of result exprs in query stmt. So I think it is not match.
##########
File path: fe/src/main/java/org/apache/doris/analysis/InsertStmt.java
##########
@@ -453,6 +453,26 @@ private void analyzeSubquery(Analyzer analyzer) throws
UserException {
}
}
+ //Get the correspondence of this column to the original column through
defineExpr
Review comment:
Please add example of mv column and schema change column
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]