@Override
  public List<String> getTables(String dbname, String tablePattern, TableType tableType) throws MetaException {
    List<String> tableNames = super.getTables(dbname, tablePattern, tableType);

    if (tableType == TableType.MANAGED_TABLE || tableType == TableType.EXTERNAL_TABLE) {
      // May need to merge with list of temp tables
      dbname = dbname.toLowerCase();
      tablePattern = tablePattern.toLowerCase();
      Map<String, Table> tables = getTempTablesForDatabase(dbname, tablePattern);
      if (tables == null || tables.size() == 0) {
        return tableNames;
      }
      tablePattern = tablePattern.replaceAll("(?<!\\.)\\*", ".*");
      Pattern pattern = Pattern.compile(tablePattern);
      Matcher matcher = pattern.matcher("");
      Set<String> combinedTableNames = new HashSet<String>();
      combinedTableNames.addAll(tableNames);
      for (Entry<String, Table> tableData : tables.entrySet()) {
        matcher.reset(tableData.getKey());
        if (matcher.matches()) {
          if (tableData.getValue().getTableType() == tableType) {
            // If tableType is the same that we are requesting,
            // add table the the list
            combinedTableNames.add(tableData.getKey());
          } else {
            // If tableType is not the same that we are requesting,
            // remove it in case it was added before, as temp table
            // overrides original table
            combinedTableNames.remove(tableData.getKey());
          }
        }
      }
      // Combine/sort temp and normal table results
      tableNames = new ArrayList<>(combinedTableNames);
      Collections.sort(tableNames);
    }

    return tableNames;
  }
todo: This need review re: thread safety.  Various places (see callsers of
{@link SessionState#setCurrentSessionState(SessionState)}) pass SessionState to forked threads.
Currently it looks like those threads only read metadata but this is fragile.
Also, maps (in SessionState) where tempt table metadata is stored are concurrent and so
any put/get crosses a memory barrier and so does using most {@code java.util.concurrent.*}
so the readers of the objects in these maps should have the most recent view of the object.
But again, could be fragile.
ql/src/java/org/apache/hadoop/hive/ql/metadata/SessionHiveMetaStoreClient.java