Skip to content
Merged

fix p0 #33210

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class AnalyzeProperties {
public static final String PROPERTY_PERIOD_SECONDS = "period.seconds";
public static final String PROPERTY_FORCE_FULL = "force.full";
public static final String PROPERTY_PARTITION_COLUMN_FROM_SQL = "partition.column.from.sql";
public static final String PROPERTY_USE_AUTO_ANALYZER = "use.auto.analyzer";

public static final AnalyzeProperties DEFAULT_PROP = new AnalyzeProperties(new HashMap<String, String>() {
{
Expand Down Expand Up @@ -72,6 +73,7 @@ public class AnalyzeProperties {
.add(PROPERTY_PERIOD_CRON)
.add(PROPERTY_FORCE_FULL)
.add(PROPERTY_PARTITION_COLUMN_FROM_SQL)
.add(PROPERTY_USE_AUTO_ANALYZER)
.build();

public AnalyzeProperties(Map<String, String> properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -1319,7 +1318,7 @@ public Set<Pair<String, String>> getColumnIndexPairs(Set<String> columns) {
if (col == null || StatisticsUtil.isUnsupportedType(col.getType())) {
continue;
}
ret.add(Pair.of(getIndexNameById(meta.getIndexId()), column.toLowerCase(Locale.ROOT)));
ret.add(Pair.of(getIndexNameById(meta.getIndexId()), column));
}
}
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -320,7 +319,7 @@ public Set<Pair<String, String>> getColumnIndexPairs(Set<String> columns) {
continue;
}
// External table put table name as index name.
ret.add(Pair.of(String.valueOf(name), column.toLowerCase(Locale.ROOT)));
ret.add(Pair.of(String.valueOf(name), column));
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public List<AnalysisInfo> buildAnalysisInfosForDB(DatabaseIf<TableIf> db, Analyz
// Each analyze stmt corresponding to an analysis job.
public void createAnalysisJob(AnalyzeTblStmt stmt, boolean proxy) throws DdlException {
// Using auto analyzer if user specifies.
if (stmt.getAnalyzeProperties().getProperties().containsKey("use.auto.analyzer")) {
if ("true".equalsIgnoreCase(stmt.getAnalyzeProperties().getProperties().get("use.auto.analyzer"))) {
Env.getCurrentEnv().getStatisticsAutoCollector()
.processOneJob(stmt.getTable(),
stmt.getTable().getColumnIndexPairs(stmt.getColumnNames()), JobPriority.HIGH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ protected void doFull() throws Exception {
params.put("tblName", String.valueOf(tbl.getName()));
params.put("index", getIndex());
StringSubstitutor stringSubstitutor = new StringSubstitutor(params);
String collectColStats = stringSubstitutor.replace(FULL_ANALYZE_TEMPLATE);
runQuery(collectColStats);
runQuery(stringSubstitutor.replace(FULL_ANALYZE_TEMPLATE));
}

protected String getIndex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ suite("test_hive_statistic_auto", "p2,external,hive,external_remote,external_rem
logger.info("catalog " + catalog_name + " created")

// Test analyze table without init.
sql """analyze database ${catalog_name}.statistics PROPERTIES("use.auto.analyzer"="true")"""
sql """analyze table ${catalog_name}.statistics.statistics PROPERTIES("use.auto.analyzer"="true")"""
sql """use ${catalog_name}.statistics"""

for (int i = 0; i < 10; i++) {
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/statistics/analyze_stats.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,7 @@ PARTITION `p599` VALUES IN (599)

// Test auto analyze with job type SYSTEM
sql """drop stats trigger_test"""
sql """analyze database trigger PROPERTIES("use.auto.analyzer"="true")"""
sql """analyze table trigger_test PROPERTIES("use.auto.analyzer"="true")"""
int i = 0;
for (0; i < 10; i++) {
result = sql """show column stats trigger_test"""
Expand Down