rtrivedi12 commented on code in PR #6683:
URL: https://github.com/apache/hive/pull/6683#discussion_r4354207474
##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/info/show/status/ShowTableStatusAnalyzer.java:
##########
@@ -81,4 +89,24 @@ public void analyzeInternal(ASTNode root) throws
SemanticException {
task.setFetchSource(true);
setFetchTask(createFetchTask(ShowTableStatusDesc.SCHEMA));
}
+
+ /**
+ * Register table read inputs for authorization. Resolves the SQL LIKE
pattern against the tables
+ * in the database the same way {@link ShowTableStatusOperation} does, so
every table whose
+ * metadata is returned is authorized.
+ */
+ private void addReadEntitiesForShowTableExtendedPattern(String dbName,
String pattern)
+ throws SemanticException {
+ try {
+ Pattern likePattern =
Pattern.compile(UDFLike.likePatternToRegExp(pattern),
+ Pattern.CASE_INSENSITIVE);
+ for (String name : db.getTablesForDb(dbName, null)) {
Review Comment:
Thanks @saihemanth-cloudera for pointing this out. I missed this point
earlier !
I want to know your thoughts on this approach to fix this -
- Resolve once in the analyzer. List the tables, filter them with
`UDFLike.likePatternToRegExp`, sort them, fetch each matching Table, and
register a ReadEntity for each one (same as now).
- Pass the resolved list to the operation. Add a List<Table> field to
`ShowTableStatusDesc`
This way the set that gets authorized is exactly the set whose metadata is
returned. It also takes care of your second comment: each table is fetched once
instead of twice. `AlterTableExchangePartitionsDesc` also passes Table objects
through a desc in similar way.
--
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]