vdiravka commented on a change in pull request #1706: DRILL-7115: Improve Hive
schema show tables performance
URL: https://github.com/apache/drill/pull/1706#discussion_r267900169
##########
File path:
contrib/storage-hive/core/src/main/java/org/apache/drill/exec/store/hive/schema/HiveDatabaseSchema.java
##########
@@ -63,14 +60,35 @@ public Table getTable(String tableName) {
return hiveSchema.getDrillTable(this.name, tableName);
}
+ @Override
+ public List<Pair<String, TableType>> getTableNamesAndTypes() {
+ Set<String> views = getViewNames();
+ // optimization for empty views
+ Function<String, Pair<String, TableType>> toNameAndTypePair =
views.isEmpty()
+ ? (name) -> Pair.of(name, TableType.TABLE)
+ : (name) -> Pair.of(name, views.contains(name) ? TableType.VIEW :
TableType.TABLE);
+ return getTableNames().stream()
+ .map(toNameAndTypePair)
+ .collect(toList());
+ }
+
+ private Set<String> getViewNames() {
+ try {
+ return new HashSet<>(mClient.getTables(this.name, "*",
org.apache.hadoop.hive.metastore.TableType.VIRTUAL_VIEW));
+ } catch (MetaException e) {
+ logger.warn("Failed to get view names, views and tables won't be
separated by type.", e.getCause());
Review comment:
```suggestion
logger.warn("Failed to get view names. Views and tables won't be
separated by type.", e.getCause());
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services