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 alter for rel groups #4764

Merged
merged 2 commits into from
Jan 23, 2025
Merged

Support alter for rel groups #4764

merged 2 commits into from
Jan 23, 2025

Conversation

royi-luo
Copy link
Collaborator

@royi-luo royi-luo commented Jan 21, 2025

Description

  • Support ALTER on rel groups, propagating the changes to the child tables
  • Move most validation functions for alter from binder to alter operator

TODOs:

  • Add more tests
    • WAL replaying alter (there's a single test in rollback.test)
    • Alter conflict handling on rel groups

Fixed #4762 as well.

Contributor agreement

@royi-luo royi-luo self-assigned this Jan 21, 2025
void CatalogSet::alterEntry(Transaction* transaction, const binder::BoundAlterInfo& alterInfo) {
void CatalogSet::alterRelGroupEntry(Transaction* transaction,
const binder::BoundAlterInfo& alterInfo) {
CatalogEntry* entry = nullptr;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A good amount of this is duplicated with alterTableEntry it might be good to refactor out some of the duplicate logic

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 82.01058% with 34 lines in your changes missing coverage. Please review.

Project coverage is 86.29%. Comparing base (d1c83e9) to head (67cf682).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/storage/wal/wal_record.cpp 29.41% 12 Missing ⚠️
src/storage/wal_replayer.cpp 0.00% 7 Missing ⚠️
src/storage/wal/wal.cpp 0.00% 4 Missing ⚠️
src/binder/bind/bind_ddl.cpp 88.46% 3 Missing ⚠️
src/include/storage/wal/wal_record.h 0.00% 3 Missing ⚠️
src/processor/operator/ddl/alter.cpp 97.64% 2 Missing ⚠️
src/catalog/catalog.cpp 92.30% 1 Missing ⚠️
.../catalog/catalog_entry/rel_group_catalog_entry.cpp 66.66% 1 Missing ⚠️
.../catalog/catalog_entry/rel_table_catalog_entry.cpp 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4764      +/-   ##
==========================================
- Coverage   86.32%   86.29%   -0.03%     
==========================================
  Files        1397     1397              
  Lines       59840    60003     +163     
  Branches     7377     7390      +13     
==========================================
+ Hits        51656    51779     +123     
- Misses       8017     8057      +40     
  Partials      167      167              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +37 to +43
KU_ASSERT(tableAlterInfo.tableName.starts_with(relGroupEntry->getName()));
// table name is in format {rel_group_name}{suffix}
// rename to {new_rel_group_name}{suffix}
auto& renameInfo = tableAlterInfo.extraInfo->cast<BoundExtraRenameTableInfo>();
auto tableNameSuffix = tableEntry->getName().substr(relGroupEntry->getName().size());
renameInfo.newName.append(tableNameSuffix);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

do we want renaming rel group to also rename the child tables?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. I guess it's better to also rename children tables so that the naming convention if preserved after ALTER

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also rename the child tables to maintain consistency. Later, we might consider removing table names from the Catalog entirely.

Copy link
Contributor

@andyfengHKU andyfengHKU left a comment

Choose a reason for hiding this comment

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

Overall LGTM.

@ray6080 should check if the new record can be omitted and if we need to store alterInfo in TableCatalogEntry.

src/binder/binder.cpp Outdated Show resolved Hide resolved
Comment on lines +37 to +43
KU_ASSERT(tableAlterInfo.tableName.starts_with(relGroupEntry->getName()));
// table name is in format {rel_group_name}{suffix}
// rename to {new_rel_group_name}{suffix}
auto& renameInfo = tableAlterInfo.extraInfo->cast<BoundExtraRenameTableInfo>();
auto tableNameSuffix = tableEntry->getName().substr(relGroupEntry->getName().size());
renameInfo.newName.append(tableNameSuffix);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure. I guess it's better to also rename children tables so that the naming convention if preserved after ALTER

const auto* tableEntry = catalog->getTableCatalogEntry(transaction, tableID);
BoundAlterInfo tableAlterInfo = info.copy();
tableAlterInfo.tableName = tableEntry->getName();
if (tableAlterInfo.alterType == common::AlterType::RENAME_TABLE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's better to do this in bind_ddl.cpp?

@ray6080 ray6080 self-requested a review January 22, 2025 02:40
@ray6080 ray6080 force-pushed the royi/rel-group-alter branch from 70f3248 to 351e37b Compare January 22, 2025 09:36
@ray6080 ray6080 marked this pull request as ready for review January 22, 2025 10:08
@ray6080 ray6080 removed the request for review from benjaminwinger January 22, 2025 11:42
@ray6080 ray6080 force-pushed the royi/rel-group-alter branch from 6d09d27 to 9a5eaf1 Compare January 22, 2025 11:44
Copy link

Benchmark Result

Master commit hash: 99dd5dca0fa03b0ca9af007f794b2e85c497c9a5
Branch commit hash: 3931d77c5a09167ef9b7f516e9e8fa7e76b090be

Query Group Query Name Mean Time - Commit (ms) Mean Time - Master (ms) Diff
aggregation q24 641.31 639.72 1.58 (0.25%)
aggregation q28 11163.53 11523.78 -360.25 (-3.13%)
filter q14 127.75 129.41 -1.66 (-1.28%)
filter q15 131.03 127.07 3.96 (3.12%)
filter q16 302.27 305.87 -3.60 (-1.18%)
filter q17 446.65 446.23 0.42 (0.09%)
filter q18 1914.97 1926.06 -11.09 (-0.58%)
filter zonemap-node 92.00 88.56 3.44 (3.88%)
filter zonemap-node-lhs-cast 90.36 89.70 0.65 (0.73%)
filter zonemap-node-null 85.34 85.53 -0.18 (-0.22%)
filter zonemap-rel 5868.48 5818.59 49.89 (0.86%)
fixed_size_expr_evaluator q07 574.84 583.91 -9.07 (-1.55%)
fixed_size_expr_evaluator q08 804.01 808.83 -4.82 (-0.60%)
fixed_size_expr_evaluator q09 806.09 810.24 -4.14 (-0.51%)
fixed_size_expr_evaluator q10 239.21 248.17 -8.96 (-3.61%)
fixed_size_expr_evaluator q11 232.78 240.45 -7.67 (-3.19%)
fixed_size_expr_evaluator q12 229.20 236.17 -6.97 (-2.95%)
fixed_size_expr_evaluator q13 1457.19 1458.38 -1.19 (-0.08%)
fixed_size_seq_scan q23 112.78 122.21 -9.44 (-7.72%)
join q29 614.87 613.07 1.80 (0.29%)
join q30 10512.26 10249.64 262.62 (2.56%)
join q31 5.90 4.49 1.41 (31.50%)
join SelectiveTwoHopJoin 56.44 53.25 3.20 (6.00%)
ldbc_snb_ic q35 2551.34 2620.03 -68.69 (-2.62%)
ldbc_snb_ic q36 455.64 451.14 4.51 (1.00%)
ldbc_snb_is q32 3.85 6.09 -2.25 (-36.88%)
ldbc_snb_is q33 9.59 14.13 -4.54 (-32.11%)
ldbc_snb_is q34 1.37 1.37 0.00 (0.37%)
multi-rel multi-rel-large-scan 1329.35 1410.09 -80.74 (-5.73%)
multi-rel multi-rel-lookup 32.01 33.52 -1.51 (-4.51%)
multi-rel multi-rel-small-scan 98.43 91.85 6.57 (7.16%)
order_by q25 132.60 134.38 -1.79 (-1.33%)
order_by q26 470.79 471.36 -0.56 (-0.12%)
order_by q27 1453.64 1470.36 -16.72 (-1.14%)
recursive_join recursive-join-bidirection 301.50 276.38 25.12 (9.09%)
recursive_join recursive-join-dense 7346.96 7357.94 -10.98 (-0.15%)
recursive_join recursive-join-path 23643.29 23584.85 58.43 (0.25%)
recursive_join recursive-join-sparse 1064.06 1065.69 -1.63 (-0.15%)
recursive_join recursive-join-trail 7349.66 7328.53 21.13 (0.29%)
scan_after_filter q01 171.30 170.29 1.01 (0.59%)
scan_after_filter q02 156.29 156.97 -0.68 (-0.43%)
shortest_path_ldbc100 q37 89.74 89.83 -0.10 (-0.11%)
shortest_path_ldbc100 q38 356.54 372.42 -15.88 (-4.26%)
shortest_path_ldbc100 q39 63.11 63.85 -0.74 (-1.15%)
shortest_path_ldbc100 q40 452.05 474.96 -22.91 (-4.82%)
var_size_expr_evaluator q03 2049.75 2087.52 -37.77 (-1.81%)
var_size_expr_evaluator q04 2225.61 2233.12 -7.51 (-0.34%)
var_size_expr_evaluator q05 2640.86 2644.47 -3.61 (-0.14%)
var_size_expr_evaluator q06 1329.51 1326.85 2.66 (0.20%)
var_size_seq_scan q19 1449.59 1451.82 -2.23 (-0.15%)
var_size_seq_scan q20 2773.40 2717.07 56.33 (2.07%)
var_size_seq_scan q21 2324.64 2299.77 24.87 (1.08%)
var_size_seq_scan q22 125.14 126.94 -1.80 (-1.42%)

@kuzudb kuzudb deleted a comment from github-actions bot Jan 22, 2025
@kuzudb kuzudb deleted a comment from github-actions bot Jan 22, 2025
@kuzudb kuzudb deleted a comment from github-actions bot Jan 22, 2025
@ray6080 ray6080 removed their request for review January 22, 2025 15:16
Copy link

Benchmark Result

Master commit hash: 3900ed5623a041dcfc8699fd35a3a56a0dc257ce
Branch commit hash: 41a74adb2f47894dc3342a64b6ee9f2c033bb9ad

Query Group Query Name Mean Time - Commit (ms) Mean Time - Master (ms) Diff
aggregation q24 691.75 694.16 -2.42 (-0.35%)
aggregation q28 6081.52 6135.52 -54.00 (-0.88%)
copy node-Comment 74329.82 N/A N/A
copy node-Forum 5851.09 N/A N/A
copy node-Organisation 1222.97 N/A N/A
copy node-Person 2085.68 N/A N/A
copy node-Place 1195.85 N/A N/A
copy node-Post 30793.25 N/A N/A
copy node-Tag 1260.44 N/A N/A
copy node-Tagclass 1148.95 N/A N/A
copy rel-comment-hasCreator 56478.37 N/A N/A
copy rel-comment-hasTag 90759.11 N/A N/A
copy rel-comment-isLocatedIn 72851.38 N/A N/A
copy rel-containerOf 15565.34 N/A N/A
copy rel-forum-hasTag 4058.97 N/A N/A
copy rel-hasInterest 3110.83 N/A N/A
copy rel-hasMember 119603.69 N/A N/A
copy rel-hasModerator 1301.49 N/A N/A
copy rel-hasType 279.29 N/A N/A
copy rel-isPartOf 259.65 N/A N/A
copy rel-isSubclassOf 225.05 N/A N/A
copy rel-knows 13566.49 N/A N/A
copy rel-likes-comment 172220.22 N/A N/A
copy rel-likes-post 69059.81 N/A N/A
copy rel-organisation-isLocatedIn 247.27 N/A N/A
copy rel-person-isLocatedIn 497.64 N/A N/A
copy rel-post-hasCreator 14900.51 N/A N/A
copy rel-post-hasTag 23929.70 N/A N/A
copy rel-post-isLocatedIn 19475.90 N/A N/A
copy rel-replyOf-comment 49752.48 N/A N/A
copy rel-replyOf-post 38226.24 N/A N/A
copy rel-studyAt 856.23 N/A N/A
copy rel-workAt 1620.33 N/A N/A
filter q14 126.85 125.69 1.17 (0.93%)
filter q15 127.40 131.73 -4.33 (-3.28%)
filter q16 306.75 319.73 -12.98 (-4.06%)
filter q17 446.62 447.14 -0.52 (-0.12%)
filter q18 1926.52 1939.95 -13.43 (-0.69%)
filter zonemap-node 91.12 88.70 2.42 (2.73%)
filter zonemap-node-lhs-cast 89.13 89.76 -0.63 (-0.71%)
filter zonemap-node-null 85.23 85.37 -0.15 (-0.17%)
filter zonemap-rel 5723.37 5657.63 65.74 (1.16%)
fixed_size_expr_evaluator q07 573.93 574.37 -0.44 (-0.08%)
fixed_size_expr_evaluator q08 802.55 800.97 1.58 (0.20%)
fixed_size_expr_evaluator q09 807.22 802.05 5.17 (0.64%)
fixed_size_expr_evaluator q10 236.52 423.75 -187.23 (-44.18%)
fixed_size_expr_evaluator q11 230.28 231.10 -0.82 (-0.36%)
fixed_size_expr_evaluator q12 226.43 227.67 -1.24 (-0.55%)
fixed_size_expr_evaluator q13 1457.07 1470.43 -13.36 (-0.91%)
fixed_size_seq_scan q23 115.66 127.42 -11.76 (-9.23%)
join q29 592.26 602.62 -10.36 (-1.72%)
join q30 9867.22 10388.23 -521.00 (-5.02%)
join q31 7.28 5.51 1.76 (31.99%)
join SelectiveTwoHopJoin 53.53 53.68 -0.15 (-0.29%)
ldbc_snb_ic q35 2615.33 2493.54 121.79 (4.88%)
ldbc_snb_ic q36 503.94 487.00 16.94 (3.48%)
ldbc_snb_is q32 7.05 5.82 1.23 (21.07%)
ldbc_snb_is q33 20.40 13.48 6.92 (51.37%)
ldbc_snb_is q34 1.38 1.43 -0.05 (-3.39%)
multi-rel multi-rel-large-scan 1302.91 1317.09 -14.19 (-1.08%)
multi-rel multi-rel-lookup 26.87 35.80 -8.93 (-24.94%)
multi-rel multi-rel-small-scan 91.52 94.32 -2.80 (-2.97%)
order_by q25 133.88 133.41 0.47 (0.36%)
order_by q26 451.60 451.41 0.19 (0.04%)
order_by q27 1450.98 1453.12 -2.14 (-0.15%)
recursive_join recursive-join-bidirection 287.55 287.44 0.11 (0.04%)
recursive_join recursive-join-dense 7335.85 7335.21 0.63 (0.01%)
recursive_join recursive-join-path 23578.21 23480.96 97.25 (0.41%)
recursive_join recursive-join-sparse 1063.36 1057.62 5.74 (0.54%)
recursive_join recursive-join-trail 7310.08 7319.21 -9.13 (-0.12%)
scan_after_filter q01 175.63 172.24 3.39 (1.97%)
scan_after_filter q02 162.35 158.05 4.30 (2.72%)
shortest_path_ldbc100 q37 89.50 92.59 -3.09 (-3.34%)
shortest_path_ldbc100 q38 373.11 377.78 -4.67 (-1.24%)
shortest_path_ldbc100 q39 63.48 62.75 0.73 (1.16%)
shortest_path_ldbc100 q40 398.30 458.83 -60.53 (-13.19%)
var_size_expr_evaluator q03 2049.36 2059.14 -9.79 (-0.48%)
var_size_expr_evaluator q04 2205.70 2231.35 -25.65 (-1.15%)
var_size_expr_evaluator q05 2679.38 2593.36 86.02 (3.32%)
var_size_expr_evaluator q06 1346.08 1323.22 22.86 (1.73%)
var_size_seq_scan q19 1444.35 1435.43 8.92 (0.62%)
var_size_seq_scan q20 2660.42 2622.40 38.02 (1.45%)
var_size_seq_scan q21 2293.99 2257.93 36.06 (1.60%)
var_size_seq_scan q22 125.05 124.69 0.37 (0.30%)

@@ -278,7 +278,9 @@ class Binder {
const BoundProjectionBody& boundProjectionBody);
static bool isOrderByKeyTypeSupported(const common::LogicalType& dataType);

void validateTableExist(const std::string& tableName) const;
void validateTableExists(const std::string& name) const;
void validateNoIndexOnProperty(const std::string& tableName,
Copy link
Contributor

Choose a reason for hiding this comment

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

These two can be hide in bind_ddl.cpp right?

@andyfengHKU andyfengHKU merged commit 6137fa4 into master Jan 23, 2025
@andyfengHKU andyfengHKU deleted the royi/rel-group-alter branch January 23, 2025 07:49
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.

Improve error message when trying to drop a property on a table associated with an index
3 participants