This is an automated email from the ASF dual-hosted git repository. shahrs87 pushed a commit to branch PHOENIX-6883-feature in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/PHOENIX-6883-feature by this push: new 8840cb6f81 PHOENIX-7294 : Validate DDL timestamps only for Tables, Views and Indexes (#1865) 8840cb6f81 is described below commit 8840cb6f814a0668877cfd472de71014e2954758 Author: palash <palashc...@gmail.com> AuthorDate: Fri Mar 29 19:23:50 2024 -0700 PHOENIX-7294 : Validate DDL timestamps only for Tables, Views and Indexes (#1865) --- .../phoenix/util/ValidateLastDDLTimestampUtil.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ValidateLastDDLTimestampUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ValidateLastDDLTimestampUtil.java index 7d77e6aa89..bc1ae34f6a 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/util/ValidateLastDDLTimestampUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/util/ValidateLastDDLTimestampUtil.java @@ -18,9 +18,11 @@ package org.apache.phoenix.util; import java.sql.SQLException; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.ServerName; @@ -35,6 +37,7 @@ import org.apache.phoenix.query.QueryServicesOptions; import org.apache.phoenix.schema.PName; import org.apache.phoenix.schema.PTable; import org.apache.phoenix.schema.PTableKey; +import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.TableRef; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,6 +51,8 @@ public class ValidateLastDDLTimestampUtil { private static final Logger LOGGER = LoggerFactory .getLogger(ValidateLastDDLTimestampUtil.class); + private static final List<PTableType> ALLOWED_PTABLE_TYPES = Arrays.asList(new PTableType[] + {PTableType.TABLE, PTableType.VIEW, PTableType.INDEX, PTableType.SYSTEM}); public static String getInfoString(PName tenantId, List<TableRef> tableRefs) { StringBuilder sb = new StringBuilder(); @@ -76,13 +81,14 @@ public class ValidateLastDDLTimestampUtil { * A random live region server is picked for invoking the RPC to validate LastDDLTimestamp. * Retry once if there was an error performing the RPC, otherwise throw the Exception. * - * @param tableRefs + * @param allTableRefs * @param doRetry * @throws SQLException */ public static void validateLastDDLTimestamp(PhoenixConnection conn, - List<TableRef> tableRefs, + List<TableRef> allTableRefs, boolean doRetry) throws SQLException { + List<TableRef> tableRefs = filterTableRefs(allTableRefs); String infoString = getInfoString(conn.getTenantId(), tableRefs); try (Admin admin = conn.getQueryServices().getAdmin()) { // get all live region servers @@ -198,4 +204,16 @@ public class ValidateLastDDLTimestampUtil { builder.setTableName(ByteStringer.wrap(tableName.getBytes())); builder.setLastDDLTimestamp(lastDDLTimestamp); } + + /** + * Filter out any TableRefs which are not tables, views or indexes. + * @param tableRefs + * @return + */ + private static List<TableRef> filterTableRefs(List<TableRef> tableRefs) { + List<TableRef> filteredTableRefs = tableRefs.stream() + .filter(tableRef -> ALLOWED_PTABLE_TYPES.contains(tableRef.getTable().getType())) + .collect(Collectors.toList()); + return filteredTableRefs; + } }