Signed-off-by: Seaven <seaven_7@qq.com> Co-authored-by: Seaven <seaven_7@qq.com>
This commit is contained in:
parent
898d7a400e
commit
288b12572d
|
|
@ -438,9 +438,17 @@ public class StatisticUtils {
|
|||
List<String> columns = new ArrayList<>();
|
||||
for (Column column : table.getBaseSchema()) {
|
||||
// disable stats collection for auto generated columns, see SelectAnalyzer#analyzeSelect
|
||||
if (column.isGeneratedColumn() && column.getName().startsWith(FeConstants.GENERATED_PARTITION_COLUMN_PREFIX)) {
|
||||
if (column.isGeneratedColumn() && column.getName()
|
||||
.startsWith(FeConstants.GENERATED_PARTITION_COLUMN_PREFIX)) {
|
||||
continue;
|
||||
}
|
||||
// generated column doesn't support cross DB use
|
||||
if (column.isGeneratedColumn() && column.generatedColumnExprToString() != null) {
|
||||
String expr = column.generatedColumnExprToString().toLowerCase();
|
||||
if (expr.contains("dict_mapping") || expr.contains("dictionary_get")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!column.isAggregated()) {
|
||||
columns.add(column.getName());
|
||||
} else if (isPrimaryEngine && column.getAggregationType().equals(AggregateType.REPLACE)) {
|
||||
|
|
|
|||
|
|
@ -14,14 +14,19 @@
|
|||
|
||||
package com.starrocks.sql.analyzer;
|
||||
|
||||
import com.starrocks.catalog.OlapTable;
|
||||
import com.starrocks.common.Config;
|
||||
import com.starrocks.qe.ConnectContext;
|
||||
import com.starrocks.server.RunMode;
|
||||
import com.starrocks.statistic.StatisticUtils;
|
||||
import com.starrocks.utframe.StarRocksAssert;
|
||||
import com.starrocks.utframe.UtFrameUtils;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DictQueryFunctionTest {
|
||||
|
||||
private static final String TEST_DICT_DATABASE = "dict";
|
||||
|
|
@ -160,6 +165,25 @@ public class DictQueryFunctionTest {
|
|||
RunMode.detectRunMode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDictTable() throws Exception {
|
||||
starRocksAssert.useDatabase(TEST_DICT_DATABASE);
|
||||
starRocksAssert.withTable("CREATE TABLE `dd0` (\n" +
|
||||
" `k1` int(11) NOT NULL,\n" +
|
||||
" `k2` BIGINT(11) NULL AS dict_mapping('dict_table', `k1`, TRUE)\n" +
|
||||
") ENGINE=OLAP\n" +
|
||||
"DUPLICATE KEY(`k1`)\n" +
|
||||
"PROPERTIES (\n" +
|
||||
"\"replication_num\" = \"1\"\n" +
|
||||
");");
|
||||
|
||||
OlapTable table = (OlapTable) starRocksAssert.getTable(TEST_DICT_DATABASE, "dd0");
|
||||
List<String> cols = StatisticUtils.getCollectibleColumns(table);
|
||||
Assertions.assertEquals(1, cols.size());
|
||||
|
||||
starRocksAssert.dropTable("dd0");
|
||||
}
|
||||
|
||||
private void testDictMappingFunction(String sql, String expectException) {
|
||||
new ExceptionChecker(sql)
|
||||
.withException(SemanticException.class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue