saihemanth-cloudera commented on code in PR #6636:
URL: https://github.com/apache/hive/pull/6636#discussion_r3706978730


##########
standalone-metastore/metastore-server/src/main/sql/postgres/rebuild-indexes.postgres.sql:
##########
@@ -0,0 +1,176 @@
+-- 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
+
+-- Rebuilds all HMS indexes on PostgreSQL.
+-- Update this file whenever a new upgrade script adds an index.
+
+DROP INDEX IF EXISTS "NOTIFICATION_LOG_EVENT_ID";
+CREATE UNIQUE INDEX "NOTIFICATION_LOG_EVENT_ID" ON "NOTIFICATION_LOG" USING 
btree ("EVENT_ID");

Review Comment:
   hive-schema-4.3.0.postgres.sql defines important uniqueness objects like 
`UNIQUE_DATABASE, UNIQUETABLE, UNIQUEPARTITION, and UNIQUE_TYPE`. This script 
only covers CREATE INDEX objects, so it cannot fully reconstruct the backend 
indexing/constraint state? 
   The new consistency test also misses this because it only extracts CREATE 
INDEX names from the init script.



##########
standalone-metastore/metastore-server/src/main/sql/oracle/rebuild-indexes.oracle.sql:
##########
@@ -0,0 +1,222 @@
+--
+-- 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.
+
+
+-- Oracle has no DROP INDEX IF EXISTS; this script uses plain DROP INDEX.
+-- If an index is already missing, comment out its DROP line before running.
+-- Update this file whenever a new upgrade script adds an index.

Review Comment:
   If the utility is run because an index is missing, Oracle fails on the first 
missing index and never reaches the create. The comment telling users to 
manually edit the script defeats the purpose of `-rebuildIndexes`. Can we use 
use PL/SQL blocks that ignore only “index does not exist”?



##########
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestRebuildIndexesScriptConsistency.java:
##########
@@ -0,0 +1,174 @@
+/*
+ * 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.
+ */
+package org.apache.hadoop.hive.metastore.tools.schematool;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo;
+import org.apache.hadoop.hive.metastore.MetaStoreSchemaInfoFactory;
+import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@Category(MetastoreUnitTest.class)
+@RunWith(Parameterized.class)
+public class TestRebuildIndexesScriptConsistency {

Review Comment:
   This would pass if a rebuild script recreated an index with the same name 
but wrong table, wrong columns, wrong order, wrong uniqueness, or wrong access 
method.
   I think the right way to test this is that, it should parse and compare at 
least index name, table, column list/order, and uniqueness; for PostgreSQL it 
also needs constraint-backed indexes. What do you think?



##########
standalone-metastore/metastore-server/src/main/sql/postgres/rebuild-indexes.postgres.sql:
##########
@@ -0,0 +1,176 @@
+-- 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
+

Review Comment:
   nit: incomplete license info.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to