[nereids] explode function stats configurable (#31332)

---------

Co-authored-by: zhongjian.xzj <zhongjian.xzj@zhongjianxzjdeMacBook-Pro.local>
This commit is contained in:
xzj7019
2024-02-29 23:52:19 +08:00
committed by yiguolei
parent d8b9909675
commit 0d77fc4847
2 changed files with 35 additions and 1 deletions

View File

@ -957,7 +957,8 @@ public class StatsCalculator extends DefaultPlanVisitor<Statistics, Void> {
private Statistics computeGenerate(Generate generate) {
Statistics stats = groupExpression.childStatistics(0);
double count = stats.getRowCount() * generate.getGeneratorOutput().size() * 5;
int statsFactor = ConnectContext.get().getSessionVariable().generateStatsFactor;
double count = stats.getRowCount() * generate.getGeneratorOutput().size() * statsFactor;
Map<Expression, ColumnStatistic> columnStatsMap = Maps.newHashMap();
for (Map.Entry<Expression, ColumnStatistic> entry : stats.columnStatistics().entrySet()) {
ColumnStatistic columnStatistic = new ColumnStatisticBuilder(entry.getValue()).setCount(count).build();

View File

@ -479,6 +479,8 @@ public class SessionVariable implements Serializable, Writable {
public static final String HUGE_TABLE_DEFAULT_SAMPLE_ROWS = "huge_table_default_sample_rows";
public static final String HUGE_TABLE_LOWER_BOUND_SIZE_IN_BYTES = "huge_table_lower_bound_size_in_bytes";
public static final String GENERATE_STATS_FACTOR = "generate_stats_factor";
public static final String HUGE_TABLE_AUTO_ANALYZE_INTERVAL_IN_MILLIS
= "huge_table_auto_analyze_interval_in_millis";
@ -740,6 +742,13 @@ public class SessionVariable implements Serializable, Writable {
@VariableMgr.VarAttr(name = ENABLE_BUCKET_SHUFFLE_DOWNGRADE, needForward = true)
public boolean enableBucketShuffleDownGrade = false;
/**
* explode function row count enlarge factor.
*/
@VariableMgr.VarAttr(name = GENERATE_STATS_FACTOR, checker = "checkGenerateStatsFactor",
setter = "setGenerateStatsFactor")
public int generateStatsFactor = 5;
@VariableMgr.VarAttr(name = PREFER_JOIN_METHOD)
public String preferJoinMethod = "broadcast";
@ -3324,6 +3333,30 @@ public class SessionVariable implements Serializable, Writable {
}
}
public void checkGenerateStatsFactor(String generateStatsFactor) {
int value = Integer.valueOf(generateStatsFactor);
if (value <= 0) {
UnsupportedOperationException exception =
new UnsupportedOperationException("Generate stats factor " + value + " should greater than 0");
LOG.warn("Check generate stats factor failed", exception);
throw exception;
}
}
public void setGenerateStatsFactor(int factor) {
this.generateStatsFactor = factor;
if (factor <= 0) {
LOG.warn("Invalid generate stats factor: {}", factor, new RuntimeException(""));
}
}
public void setGenerateStatsFactor(String factor) {
this.generateStatsFactor = Integer.valueOf(factor);
if (generateStatsFactor <= 0) {
LOG.warn("Invalid generate stats factor: {}", generateStatsFactor, new RuntimeException(""));
}
}
public boolean getEnableDescribeExtendVariantColumn() {
return enableDescribeExtendVariantColumn;
}