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

[FIX](complextype)fix array/map/struct impl hashcode and equals #27717

Merged
merged 6 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -134,6 +134,33 @@ protected void toThrift(TExprNode msg) {
msg.setChildType(((ArrayType) type).getItemType().getPrimitiveType().toThrift());
}

@Override
public int hashCode() {
int code = 31 * super.hashCode();
for (Expr c : children) {
code = code + c.hashCode();
}
return code;
amorynan marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public boolean equals(Object o) {
if (!(o instanceof ArrayLiteral)) {
return false;
}
if (this == o) {
return true;
}

ArrayLiteral that = (ArrayLiteral) o;
for (int i = 0; i < children.size(); i++) {
amorynan marked this conversation as resolved.
Show resolved Hide resolved
amorynan marked this conversation as resolved.
Show resolved Hide resolved
if (!children.get(i).equals(that.children.get(i))) {
return false;
}
}
return true;
}

@Override
public void write(DataOutput out) throws IOException {
super.write(out);
Expand Down
27 changes: 27 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/analysis/MapLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,31 @@ public void write(DataOutput out) throws IOException {
Expr.writeTo(e, out);
}
}

@Override
public int hashCode() {
int code = 31 * super.hashCode();
for (Expr c : children) {
code = code + c.hashCode();
}
return code;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof MapLiteral)) {
amorynan marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
if (this == o) {
return true;
}

MapLiteral that = (MapLiteral) o;
for (int i = 0; i < children.size(); i++) {
amorynan marked this conversation as resolved.
Show resolved Hide resolved
if (!children.get(i).equals(that.children.get(i))) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,30 @@ public void checkValueValid() throws AnalysisException {
e.checkValueValid();
}
}

public int hashCode() {
int code = 31 * super.hashCode();
for (Expr c : children) {
code = code + c.hashCode();
}
return code;
}

@Override
public boolean equals(Object o) {
if (!(o instanceof StructLiteral)) {
amorynan marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
if (this == o) {
return true;
}

StructLiteral that = (StructLiteral) o;
for (int i = 0; i < children.size(); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

check children.size() equal first to avoid index out of bound

if (!children.get(i).equals(that.children.get(i))) {
return false;
}
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !q04 --
0

-- !q04_2 --
0

-- !q04_3 --
1

-- !q04_4 --
1

-- !q04_5 --
1

-- !q04_6 --
1

-- !q04_7 --
22,25,34

-- !q04_8 --

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
DROP TABLE IF EXISTS ads_pi_cuser_all_info;
CREATE TABLE IF NOT EXISTS ads_pi_cuser_all_info (
`corp_id` varchar(64) NOT NULL COMMENT '机构ID',
`staff_id` varchar(64) NOT NULL COMMENT '客户经理ID',
`external_user_id` varchar(64) NOT NULL COMMENT '外部联系人ID',
`is_deleted` int(11) REPLACE_IF_NOT_NULL NULL COMMENT '删除好友标识',
`main_id` largeint(40) REPLACE_IF_NOT_NULL NULL COMMENT '用户main_id',
`birthday` varchar(32) REPLACE_IF_NOT_NULL NULL COMMENT '客户生日',
`gender` tinyint(4) REPLACE_IF_NOT_NULL NULL COMMENT '用户性别',
`avater` text REPLACE_IF_NOT_NULL NULL COMMENT '用户头像地址',
`name` text REPLACE_IF_NOT_NULL NULL COMMENT '用户姓名',
`remark_name` text REPLACE_IF_NOT_NULL NULL COMMENT '客户经理备注姓名',
`type` tinyint(4) REPLACE_IF_NOT_NULL NULL,
`client_number` varchar(64) REPLACE_IF_NOT_NULL NULL COMMENT '上一次行为码',
`M0000001` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000002` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000003` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000004` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000005` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000006` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000007` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000008` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000009` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000010` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000011` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000012` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000013` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000014` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000015` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000016` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000017` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000018` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000019` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`M0000020` int(11) SUM NOT NULL DEFAULT "0" COMMENT '预设用例分值,1000000取余',
`product_reach_times` int(11) SUM NOT NULL DEFAULT "0" COMMENT '本周产品触达次数,每自然周自动清零',
`common_reach_times` int(11) SUM NOT NULL DEFAULT "0" COMMENT '本周通用触达次数,每自然周自动清零',
`last_action` varchar(64) REPLACE_IF_NOT_NULL NULL COMMENT '上一次行为码',
`qw_tag_ids` text REPLACE_IF_NOT_NULL NULL COMMENT '企微标签,使用逗号分隔',
`stgy_tag_ids` text REPLACE_IF_NOT_NULL NULL COMMENT '企微标签,使用逗号分隔',
`last_reached_task_id` largeint(40) REPLACE_IF_NOT_NULL NULL COMMENT '上一次触达任务ID',
`last_reached_task_score` int(11) REPLACE_IF_NOT_NULL NULL COMMENT '上一次触达阶段分值',
`current_max_score_mode` text REPLACE_IF_NOT_NULL NULL COMMENT '分值最高的用例字段名,逗号分隔'
) ENGINE=OLAP
AGGREGATE KEY(`corp_id`, `staff_id`, `external_user_id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`staff_id`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"is_being_synced" = "false",
"storage_format" = "V2",
"light_schema_change" = "true",
"disable_auto_compaction" = "false",
"enable_single_replica_compaction" = "false"
);

INSERT INTO ads_pi_cuser_all_info
(corp_id, staff_id, external_user_id, is_deleted, main_id, birthday, gender, avater, name, remark_name, `type`, client_number, M0000001, M0000002, M0000003, M0000004, M0000005, M0000006, M0000007, M0000008, M0000009, M0000010, M0000011, M0000012, M0000013, M0000014, M0000015, M0000016, M0000017, M0000018, M0000019, M0000020, product_reach_times, common_reach_times, last_action, qw_tag_ids, stgy_tag_ids, last_reached_task_id, last_reached_task_score, current_max_score_mode)
VALUES('ww36b98e83f52f6bcc', '0af73fc236bf444aadc801cd4c416539', 'wmfvPXDAAA7OrmzTSkEVRkphuGx3hSVA', 0, '1604732822185627669', '', 2, 'http://wx.qlogo.cn/mmhead/9M0PhLTmTIeHGOibG2yxg90drr4nhu6NuJ5O4J9bskXicNShwsiaukk6g/0', 'mate20.0410q', 'mate20.0410q', 1, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, '45,34,22', NULL, '275', 0, NULL);
INSERT INTO ads_pi_cuser_all_info
(corp_id, staff_id, external_user_id, is_deleted, main_id, birthday, gender, avater, name, remark_name, `type`, client_number, M0000001, M0000002, M0000003, M0000004, M0000005, M0000006, M0000007, M0000008, M0000009, M0000010, M0000011, M0000012, M0000013, M0000014, M0000015, M0000016, M0000017, M0000018, M0000019, M0000020, product_reach_times, common_reach_times, last_action, qw_tag_ids, stgy_tag_ids, last_reached_task_id, last_reached_task_score, current_max_score_mode)
VALUES('ww36b98e83f52f6bcc', '0af73fc236bf444aadc801cd4c416539', 'wmfvPXDAAAHCcW-cFR5U2yPG5zfAS4rg', 0, '1600777478614724671', '', 0, 'http://wx.qlogo.cn/mmhead/Q3auHgzwzM43qyI9vM4Q8jYrdl7ia8FakbibeTWnSmTVu7QjtxHLJib2g/0', 'iPhoneXS', 'iPhoneXS', 1, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, '56,34,35', NULL, NULL, NULL);
INSERT INTO ads_pi_cuser_all_info
(corp_id, staff_id, external_user_id, is_deleted, main_id, birthday, gender, avater, name, remark_name, `type`, client_number, M0000001, M0000002, M0000003, M0000004, M0000005, M0000006, M0000007, M0000008, M0000009, M0000010, M0000011, M0000012, M0000013, M0000014, M0000015, M0000016, M0000017, M0000018, M0000019, M0000020, product_reach_times, common_reach_times, last_action, qw_tag_ids, stgy_tag_ids, last_reached_task_id, last_reached_task_score, current_max_score_mode)
VALUES('ww36b98e83f52f6bcc1', '0af73fc236bf444aadc801cd4c416539', 'wmfvPXDAAA7OrmzTSkEVRkphuGx3hSVA', 0, '1604732822185627669', '', 2, 'http://wx.qlogo.cn/mmhead/9M0PhLTmTIeHGOibG2yxg90drr4nhu6NuJ5O4J9bskXicNShwsiaukk6g/0', 'mate20.0410q', 'mate20.0410q', 1, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, '45,34', '275', 0, NULL);
INSERT INTO ads_pi_cuser_all_info
(corp_id, staff_id, external_user_id, is_deleted, main_id, birthday, gender, avater, name, remark_name, `type`, client_number, M0000001, M0000002, M0000003, M0000004, M0000005, M0000006, M0000007, M0000008, M0000009, M0000010, M0000011, M0000012, M0000013, M0000014, M0000015, M0000016, M0000017, M0000018, M0000019, M0000020, product_reach_times, common_reach_times, last_action, qw_tag_ids, stgy_tag_ids, last_reached_task_id, last_reached_task_score, current_max_score_mode)
VALUES('ww36b98e83f52f6bcc2', '0af73fc236bf444aadc801cd4c416539', 'wmfvPXDAAAHCcW-cFR5U2yPG5zfAS4rg', 0, '1600777478614724671', '', 0, 'http://wx.qlogo.cn/mmhead/Q3auHgzwzM43qyI9vM4Q8jYrdl7ia8FakbibeTWnSmTVu7QjtxHLJib2g/0', 'iPhoneXS', 'iPhoneXS', 1, '', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, '22,25,34', NULL, NULL, NULL);


select stgy_tag_ids from ads_pi_cuser_all_info WHERE arrays_overlap(split_by_string(stgy_tag_ids,','),['23','22']);

select * from ads_pi_cuser_all_info WHERE arrays_overlap(split_by_string(stgy_tag_ids,','),['23','22']) and arrays_overlap(split_by_string(stgy_tag_ids,','),['35']);
Loading