Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support array type in primary and unique key. #1723

Merged

Conversation

Linkerist
Copy link
Contributor

before this PR:

mysql> create table t1(id bigint not null, ids array<int>) primary key(id) distributed by hash(id);
ERROR 1064 (HY000): Invalid aggregate function 'REPLACE' for 'ids'
mysql> create table t2(id bigint not null, ids array<int>) unique key(id) distributed by hash(id);
ERROR 1064 (HY000): Invalid aggregate function 'REPLACE' for 'ids'
mysql>

after this PR:

mysql> create table t1(id bigint not null, ids array<int>) primary key(id) distributed by hash(id);
Query OK, 0 rows affected (0.11 sec)

mysql> desc t1;
+-------+------------+------+-------+---------+-------+
| Field | Type       | Null | Key   | Default | Extra |
+-------+------------+------+-------+---------+-------+
| id    | BIGINT     | No   | true  | NULL    |       |
| ids   | ARRAY<INT> | Yes  | false | NULL    |       |
+-------+------------+------+-------+---------+-------+
2 rows in set (0.00 sec)

mysql> create table t2(id bigint not null, ids array<int>) unique key(id) distributed by hash(id);
Query OK, 0 rows affected (0.13 sec)

mysql> desc t2;
+-------+------------+------+-------+---------+-------+
| Field | Type       | Null | Key   | Default | Extra |
+-------+------------+------+-------+---------+-------+
| id    | BIGINT     | No   | true  | NULL    |       |
| ids   | ARRAY<INT> | Yes  | false | NULL    |       |
+-------+------------+------+-------+---------+-------+
2 rows in set (0.01 sec)

mysql>

ATT, resolve #1715

support array type in primary and unique key.
@@ -174,7 +174,7 @@ public void analyze(boolean isOlap) throws AnalysisException {
String.format("Cannot specify aggregate function '%s' for key column '%s'", aggregateType,
name));
}
if (!aggregateType.checkCompatibility(type.getPrimitiveType())) {
if (!(aggregateType.checkCompatibility(type.getPrimitiveType()) || (aggregateType.isReplaceFamily() && type.isArrayType()))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| (aggregateType.isReplaceFamily() && type.isArrayType())
IMO, it's better to place this check inside ggregateType.checkCompatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the checkCompatibility is a simply table driven method, it check primitive types, the business logic of isArrayType, isHllType, isBitmapType, et al. is processed in analyze method right here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

@sduzh
Copy link
Contributor

sduzh commented Nov 30, 2021

Could you please give more test results on the reads and writes on array columns?

decster
decster previously approved these changes Nov 30, 2021
@sduzh
Copy link
Contributor

sduzh commented Nov 30, 2021

@kangkaisen @Seaven PTAL

…lement to a more specialize name, checkPrimitiveTypeCompatibility.
@decster decster merged commit 19b31fc into StarRocks:main Dec 1, 2021
@Linkerist Linkerist deleted the support_array_type_in_primary_and_unique_key branch December 1, 2021 03:07
caneGuy pushed a commit to caneGuy/starrocks that referenced this pull request Mar 28, 2023
* update

* Update hive_catalog.md
caneGuy pushed a commit to caneGuy/starrocks that referenced this pull request Mar 28, 2023
* Update SHOW CATALOGS.md (StarRocks#1716) (StarRocks#1717)

(cherry picked from commit 79ee002)

Co-authored-by: Sihui <103574525+femiiii@users.noreply.github.com>

* doc walkthrough "architecture" (StarRocks#1710) (StarRocks#1718)

* doc walkthrough "architecture"

* Update system_architecture.md

* Update system_architecture.md

(cherry picked from commit 1de4fe4)

Co-authored-by: evelyn.zhaojie <98087056+evelynzhaojie@users.noreply.github.com>

* 2.4 bugfix intoc (StarRocks#1722)

* Create k8s_operator_cn.md

* bugfix in 2.4rc

* Update TOC.md

* Update TOC.md

* update-2.4 content (StarRocks#1723) (StarRocks#1724)

* update

* Update hive_catalog.md

(cherry picked from commit 1ff43c4)

Co-authored-by: Sihui <103574525+femiiii@users.noreply.github.com>

* [Bugfix] add images for operator (StarRocks#1726)

* Add 2.4 RN in TOC (StarRocks#1727) (StarRocks#1730)

(cherry picked from commit 6b9c2b5)

Co-authored-by: 絵空事スピリット <wanglichen@starrocks.com>

* fix 2.4 (StarRocks#1731)

* [Doc] enhancement in 2.4 release note (StarRocks#1729)

* [Doc] enhancement in 2.4 release note

* Update release-2.4.md

* Update TOC.md (StarRocks#1736) (StarRocks#1737)

(cherry picked from commit ca65610)

Co-authored-by: 絵空事スピリット <wanglichen@starrocks.com>

* update toc&etl&streamLoad&loadingIntro&Export

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Sihui <103574525+femiiii@users.noreply.github.com>
Co-authored-by: evelyn.zhaojie <98087056+evelynzhaojie@users.noreply.github.com>
Co-authored-by: hellolilyliuyi <96421222+hellolilyliuyi@users.noreply.github.com>
Co-authored-by: 絵空事スピリット <wanglichen@starrocks.com>
wyb pushed a commit to wyb/starrocks that referenced this pull request Jan 9, 2024
* update

* Update hive_catalog.md

(cherry picked from commit 1ff43c4)

Co-authored-by: Sihui <103574525+femiiii@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support array type in primary key/unique key
4 participants