This is an automated email from the ASF dual-hosted git repository.
xuyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 47c89d49f0 [fix](array-type) array can not be distributed key and
aggregation key (#12082)
47c89d49f0 is described below
commit 47c89d49f004e56f27259b4eab62e7ebef48edab
Author: camby <[email protected]>
AuthorDate: Mon Aug 29 17:29:23 2022 +0800
[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 <[email protected]>
---
.../doris/analysis/HashDistributionDesc.java | 19 ++++++------
.../main/java/org/apache/doris/catalog/Type.java | 8 ++---
.../org/apache/doris/catalog/CreateTableTest.java | 2 +-
...roovy => aggregate_group_by_metric_type.groovy} | 34 ++++++++++++++++++----
4 files changed, 42 insertions(+), 21 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/HashDistributionDesc.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/HashDistributionDesc.java
index e16dd4ea11..9d9f2905ba 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/HashDistributionDesc.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/HashDistributionDesc.java
@@ -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);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
index d504e52a0a..a3d458948d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
@@ -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);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
index 90e6d0e890..870c469784 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
@@ -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'); "));
diff --git
a/regression-test/suites/query/aggregate/aggregate_group_by_hll_and_bitmap.groovy
b/regression-test/suites/query/aggregate/aggregate_group_by_metric_type.groovy
similarity index 60%
rename from
regression-test/suites/query/aggregate/aggregate_group_by_hll_and_bitmap.groovy
rename to
regression-test/suites/query/aggregate/aggregate_group_by_metric_type.groovy
index dff2b797c7..5b03d68d56 100644
---
a/regression-test/suites/query/aggregate/aggregate_group_by_hll_and_bitmap.groovy
+++
b/regression-test/suites/query/aggregate/aggregate_group_by_metric_type.groovy
@@ -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"
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]