[fix](array-type) array can not be distributed key and aggregation key (#12082)

Array column should not be distributed key or group by or aggregate key, we should forbid it before create table.
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
This commit is contained in:
camby
2022-08-29 17:29:23 +08:00
committed by GitHub
parent b2c85d753f
commit 47c89d49f0
4 changed files with 42 additions and 21 deletions

View File

@ -75,14 +75,6 @@ public class HashDistributionDesc extends DistributionDesc {
if (!distColSet.add(columnName)) {
throw new AnalysisException("Duplicated distribution column " + columnName);
}
for (ColumnDef columnDef : columnDefs) {
if (columnDef.getName().equals(columnName)) {
if (columnDef.getType().isScalarType(PrimitiveType.STRING)) {
throw new AnalysisException("String Type should not be used in distribution column["
+ columnDef.getName() + "].");
}
}
}
}
}
@ -121,8 +113,15 @@ public class HashDistributionDesc extends DistributionDesc {
throw new DdlException("Distribution column[" + colName + "] is not key column");
}
if (column.getType().isFloatingPointType()) {
throw new DdlException("Floating point type column can not be distribution column");
if (column.getType().isScalarType(PrimitiveType.STRING)) {
throw new DdlException("String Type should not be used in distribution column["
+ column.getName() + "].");
} else if (column.getType().isArrayType()) {
throw new DdlException("Array Type should not be used in distribution column["
+ column.getName() + "].");
} else if (column.getType().isFloatingPointType()) {
throw new DdlException("Floating point type should not be used in distribution column["
+ column.getName() + "].");
}
distributionColumns.add(column);

View File

@ -270,14 +270,12 @@ public abstract class Type {
// 3. don't support group by
// 4. don't support index
public boolean isOnlyMetricType() {
// now only_metric_type is the same to object_stored_type
// but actually they are not same in semantics.
return isObjectStored();
return isObjectStored() || isArrayType();
}
public static final String OnlyMetricTypeErrorMsg =
"Doris hll and bitmap column must use with specific function, and don't support filter or group by."
+ "please run 'help hll' or 'help bitmap' in your mysql client.";
"Doris hll, bitmap and array column must use with specific function, and don't support filter or group by."
+ "please run 'help hll' or 'help bitmap' or 'help array' in your mysql client.";
public boolean isHllType() {
return isScalarType(PrimitiveType.HLL);

View File

@ -230,7 +230,7 @@ public class CreateTableTest {
@Test
public void testAbnormal() throws DdlException {
ExceptionChecker.expectThrowsWithMsg(DdlException.class,
"Floating point type column can not be distribution column",
"Floating point type should not be used in distribution column",
() -> createTable("create table test.atbl1\n" + "(k1 int, k2 float)\n" + "duplicate key(k1)\n"
+ "distributed by hash(k2) buckets 1\n" + "properties('replication_num' = '1'); "));

View File

@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.
suite("aggregate_group_by_hll_and_bitmap") {
suite("aggregate_group_by_metric_type") {
def error_msg = "column must use with specific function, and don't support filter or group by"
sql "DROP TABLE IF EXISTS test_group_by_hll_and_bitmap"
sql """
@ -27,23 +28,46 @@ suite("aggregate_group_by_hll_and_bitmap") {
test {
sql "select distinct user_ids from test_group_by_hll_and_bitmap"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
exception "${error_msg}"
}
test {
sql "select distinct hll_set from test_group_by_hll_and_bitmap"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
exception "${error_msg}"
}
test {
sql "select user_ids from test_group_by_hll_and_bitmap order by user_ids"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
exception "${error_msg}"
}
test {
sql "select hll_set from test_group_by_hll_and_bitmap order by hll_set"
exception "Doris hll and bitmap column must use with specific function, and don't support filter or group by.please run 'help hll' or 'help bitmap' in your mysql client"
exception "${error_msg}"
}
sql "DROP TABLE test_group_by_hll_and_bitmap"
sql "DROP TABLE IF EXISTS test_group_by_array"
sql "ADMIN SET FRONTEND CONFIG ('enable_array_type' = 'true')"
sql """
CREATE TABLE test_group_by_array (id int, c_array array<int>) ENGINE=OLAP DUPLICATE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 1 properties("replication_num" = "1");
"""
sql "insert into test_group_by_array values(1, [1,2,3])"
test {
sql "select distinct c_array from test_group_by_array"
exception "${error_msg}"
}
test {
sql "select c_array from test_group_by_array order by c_array"
exception "${error_msg}"
}
test {
sql "select c_array,count(*) from test_group_by_array group by c_array"
exception "${error_msg}"
}
sql "DROP TABLE test_group_by_array"
}