This is an automated email from the ASF dual-hosted git repository.

jinsongzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git


The following commit(s) were added to refs/heads/master by this push:
     new ca07ab0ff [AMORO-3280] Move the pg upgrade script to the right place 
(#3281)
ca07ab0ff is described below

commit ca07ab0ffc456c3c89c3a08738b444c003765ab0
Author: Congxian Qiu <[email protected]>
AuthorDate: Fri Oct 18 17:03:39 2024 +0800

    [AMORO-3280] Move the pg upgrade script to the right place (#3281)
---
 .../resources/postgres/upgrade-0.7.0-to-0.7.1.sql  | 39 ----------------------
 amoro-ams/src/main/resources/postgres/upgrade.sql  | 25 ++++++++++++++
 2 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/amoro-ams/src/main/resources/postgres/upgrade-0.7.0-to-0.7.1.sql 
b/amoro-ams/src/main/resources/postgres/upgrade-0.7.0-to-0.7.1.sql
deleted file mode 100644
index e837c0599..000000000
--- a/amoro-ams/src/main/resources/postgres/upgrade-0.7.0-to-0.7.1.sql
+++ /dev/null
@@ -1,39 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-ALTER TABLE table_runtime RENAME TO table_runtime_backup;
-CREATE TABLE table_runtime (LIKE table_runtime_backup INCLUDING ALL)
-
-ALTER TABLE table_runtime ALTER COLUMN optimizing_status 
optimizing_status_code INT DEFAULT 7;
-CREATE INDEX idx_optimizer_status_and_time ON 
table_runtime(optimizing_status_code, optimizing_status_start_time DESC);
-
-INSERT INTO table_runtime(
-    table_id,catalog_name, db_name, table_name, 
current_snapshot_id,current_change_snapshotId, last_optimized_snapshotId,
-    last_optimized_change_snapshotId, last_major_optimizing_time, 
last_minor_optimizing_time, last_full_optimizing_time,
-    optimizing_status_code, optimizing_status_start_time, 
optimizing_process_id, optimizer_group, table_config,
-    optimizing_config, pending_input)
-SELECT  table_id,catalog_name, db_name, table_name, 
current_snapshot_id,current_change_snapshotId, last_optimized_snapshotId,
-        last_optimized_change_snapshotId, last_major_optimizing_time, 
last_minor_optimizing_time, last_full_optimizing_time,
-        CASE
-            WHEN optimizing_status = 'IDLE' THEN 700
-            WHEN optimizing_status = 'PENDING' THEN 600
-            WHEN optimizing_status = 'PLANNING' THEN 500
-            WHEN optimizing_status = 'COMMITTING' THEN 400
-            WHEN optimizing_status = 'MINOR_OPTIMIZING' THEN 300
-            WHEN optimizing_status = 'MAJOR_OPTIMIZING' THEN 200
-            WHEN optimizing_status = 'FULL_OPTIMIZING' THEN 100
-            END,
-        optimizing_status_start_time, optimizing_process_id, optimizer_group, 
table_config, optimizing_config, pending_input
-FROM table_runtime_backup;
\ No newline at end of file
diff --git a/amoro-ams/src/main/resources/postgres/upgrade.sql 
b/amoro-ams/src/main/resources/postgres/upgrade.sql
index ce3a399a6..c517de3be 100644
--- a/amoro-ams/src/main/resources/postgres/upgrade.sql
+++ b/amoro-ams/src/main/resources/postgres/upgrade.sql
@@ -26,3 +26,28 @@ ALTER TABLE table_blocker ADD UNIQUE KEY uq_prev 
(catalog_name, db_name, table_n
 -- ADD COLUMN table_summary FOR TABLE_RUNTIME
 ALTER TABLE table_runtime ADD COLUMN table_summary TEXT;
 COMMENT ON COLUMN table_runtime.table_summary IS 'Table summary data';
+
+ALTER TABLE table_runtime RENAME TO table_runtime_backup;
+CREATE TABLE table_runtime (LIKE table_runtime_backup INCLUDING ALL)
+
+ALTER TABLE table_runtime ALTER COLUMN optimizing_status 
optimizing_status_code INT DEFAULT 700;
+CREATE INDEX idx_optimizer_status_and_time ON 
table_runtime(optimizing_status_code, optimizing_status_start_time DESC);
+
+INSERT INTO table_runtime(
+    table_id,catalog_name, db_name, table_name, 
current_snapshot_id,current_change_snapshotId, last_optimized_snapshotId,
+    last_optimized_change_snapshotId, last_major_optimizing_time, 
last_minor_optimizing_time, last_full_optimizing_time,
+    optimizing_status_code, optimizing_status_start_time, 
optimizing_process_id, optimizer_group, table_config,
+    optimizing_config, pending_input)
+SELECT  table_id,catalog_name, db_name, table_name, 
current_snapshot_id,current_change_snapshotId, last_optimized_snapshotId,
+        last_optimized_change_snapshotId, last_major_optimizing_time, 
last_minor_optimizing_time, last_full_optimizing_time,
+        CASE
+            WHEN optimizing_status = 'IDLE' THEN 700
+            WHEN optimizing_status = 'PENDING' THEN 600
+            WHEN optimizing_status = 'PLANNING' THEN 500
+            WHEN optimizing_status = 'COMMITTING' THEN 400
+            WHEN optimizing_status = 'MINOR_OPTIMIZING' THEN 300
+            WHEN optimizing_status = 'MAJOR_OPTIMIZING' THEN 200
+            WHEN optimizing_status = 'FULL_OPTIMIZING' THEN 100
+            END,
+        optimizing_status_start_time, optimizing_process_id, optimizer_group, 
table_config, optimizing_config, pending_input
+FROM table_runtime_backup;
\ No newline at end of file

Reply via email to