[fix](mtmv) fix failed to specify the number of buckets when bucket auto (#28854)
Issue Number: close #xxx - fix failed to specify the number of buckets when bucket auto - delete unused SessionVariable - if mtmv used external table ,check `isMaterializedViewRewriteEnableContainForeignTable`
This commit is contained in:
@ -31,6 +31,7 @@ import org.apache.doris.catalog.PartitionItem;
|
||||
import org.apache.doris.catalog.TableIf;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.datasource.InternalCatalog;
|
||||
import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
|
||||
import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVRefreshState;
|
||||
import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVState;
|
||||
@ -256,6 +257,10 @@ public class MTMVUtil {
|
||||
if (!ctx.getSessionVariable().isEnableMaterializedViewRewrite()) {
|
||||
return res;
|
||||
}
|
||||
if (mtmvContainsExternalTable(mtmv) && !ctx.getSessionVariable()
|
||||
.isMaterializedViewRewriteEnableContainForeignTable()) {
|
||||
return res;
|
||||
}
|
||||
MTMVRelation mtmvRelation = mtmv.getRelation();
|
||||
if (mtmvRelation == null) {
|
||||
return res;
|
||||
@ -486,4 +491,14 @@ public class MTMVUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean mtmvContainsExternalTable(MTMV mtmv) {
|
||||
Set<BaseTableInfo> baseTables = mtmv.getRelation().getBaseTables();
|
||||
for (BaseTableInfo baseTableInfo : baseTables) {
|
||||
if (baseTableInfo.getCtlId() != InternalCatalog.INTERNAL_CATALOG_ID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,13 +536,18 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
|
||||
LogicalPlan logicalPlan = visitQuery(ctx.query());
|
||||
String querySql = getOriginSql(ctx.query());
|
||||
|
||||
boolean isHash = ctx.HASH() != null || ctx.RANDOM() == null;
|
||||
int bucketNum = FeConstants.default_bucket_num;
|
||||
if (isHash && ctx.INTEGER_VALUE() != null) {
|
||||
if (ctx.INTEGER_VALUE() != null) {
|
||||
bucketNum = Integer.parseInt(ctx.INTEGER_VALUE().getText());
|
||||
}
|
||||
DistributionDescriptor desc = new DistributionDescriptor(isHash, ctx.AUTO() != null,
|
||||
bucketNum, ctx.HASH() != null ? visitIdentifierList(ctx.hashKeys) : null);
|
||||
DistributionDescriptor desc = null;
|
||||
if (ctx.HASH() != null) {
|
||||
desc = new DistributionDescriptor(true, ctx.AUTO() != null, bucketNum,
|
||||
visitIdentifierList(ctx.hashKeys));
|
||||
} else if (ctx.RANDOM() != null) {
|
||||
desc = new DistributionDescriptor(false, ctx.AUTO() != null, bucketNum, null);
|
||||
}
|
||||
|
||||
Map<String, String> properties = ctx.propertyClause() != null
|
||||
? Maps.newHashMap(visitPropertyClause(ctx.propertyClause())) : Maps.newHashMap();
|
||||
String comment = ctx.STRING_LITERAL() == null ? "" : LogicalPlanBuilderAssistant.escapeBackSlash(
|
||||
|
||||
@ -451,8 +451,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
|
||||
public static final String ENABLE_DECIMAL256 = "enable_decimal256";
|
||||
|
||||
public static final String ENABLE_EXTERNAL_MV_REWRITE = "enable_external_mv_rewrite";
|
||||
public static final String ENABLE_MV_REWRITE = "enable_mv_rewrite";
|
||||
public static final String STATS_INSERT_MERGE_ITEM_COUNT = "stats_insert_merge_item_count";
|
||||
|
||||
public static final String HUGE_TABLE_DEFAULT_SAMPLE_ROWS = "huge_table_default_sample_rows";
|
||||
@ -813,12 +811,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = TRIM_TAILING_SPACES_FOR_EXTERNAL_TABLE_QUERY, needForward = true)
|
||||
public boolean trimTailingSpacesForExternalTableQuery = false;
|
||||
|
||||
@VariableMgr.VarAttr(name = ENABLE_EXTERNAL_MV_REWRITE, needForward = true)
|
||||
public boolean enableExternalMvRewrite = false;
|
||||
|
||||
@VariableMgr.VarAttr(name = ENABLE_MV_REWRITE, needForward = true)
|
||||
public boolean enableMvRewrite = false;
|
||||
|
||||
// the maximum size in bytes for a table that will be broadcast to all be nodes
|
||||
// when performing a join, By setting this value to -1 broadcasting can be disabled.
|
||||
// Default value is 1Gto
|
||||
@ -2612,22 +2604,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
: maxTableCountUseCascadesJoinReorder;
|
||||
}
|
||||
|
||||
public boolean isEnableExternalMvRewrite() {
|
||||
return enableExternalMvRewrite;
|
||||
}
|
||||
|
||||
public void setEnableExternalMvRewrite(boolean enableExternalMvRewrite) {
|
||||
this.enableExternalMvRewrite = enableExternalMvRewrite;
|
||||
}
|
||||
|
||||
public boolean isEnableMvRewrite() {
|
||||
return enableMvRewrite;
|
||||
}
|
||||
|
||||
public void setEnableMvRewrite(boolean enableMvRewrite) {
|
||||
this.enableMvRewrite = enableMvRewrite;
|
||||
}
|
||||
|
||||
public boolean isShowUserDefaultRole() {
|
||||
return showUserDefaultRole;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user