Skip to content

Commit

Permalink
[Enhancement] Disable optimize table on auto bucket table (backport #…
Browse files Browse the repository at this point in the history
…52120) (#52303)

Signed-off-by: meegoo <meegoo.sr@gmail.com>
Co-authored-by: meegoo <meegoo.sr@gmail.com>
  • Loading branch information
mergify[bot] and meegoo authored Oct 25, 2024
1 parent 1dafcae commit e9412f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ public Void visitOptimizeClause(OptimizeClause clause, ConnectContext context) {
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR, "Optimize materialized view is not supported");
}

if (olapTable.getAutomaticBucketSize() > 0) {
ErrorReport.reportSemanticException(ErrorCode.ERR_COMMON_ERROR,
"Random distribution table already supports automatic scaling and does not require optimization");
}

List<Integer> sortKeyIdxes = Lists.newArrayList();
List<ColumnDef> columnDefs = olapTable.getColumns().stream().map(Column::toColumnDef).collect(Collectors.toList());
if (clause.getSortKeys() != null) {
Expand Down
9 changes: 9 additions & 0 deletions test/sql/test_optimize_table/R/test_optimize_table
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ function: wait_optimize_table_finish()
None
-- !result

-- name: test_disable_random
create table t(k int);
-- result:
-- !result
alter table t distributed by random buckets 10;
-- result:
E: (5064, 'Getting analyzing error. Detail message: Random distribution table already supports automatic scaling and does not require optimization.')
-- !result




Expand Down
4 changes: 4 additions & 0 deletions test/sql/test_optimize_table/T/test_optimize_table
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- name: test_disable_random
create table t(k int);
alter table t distributed by random buckets 10;

-- name: test_optimize_table
create table t(k int) distributed by hash(k) buckets 10;
show partitions from t;
Expand Down

0 comments on commit e9412f6

Please sign in to comment.