@Override
  public Map<SchemaTableName, String> getViews(ConnectorSession session, SchemaTablePrefix prefix) {
    ImmutableMap.Builder<SchemaTableName, String> views = ImmutableMap.builder();
    List<SchemaTableName> tableNames;
    if (prefix.getTableName() != null) {
      tableNames =
          ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));
    } else {
      tableNames = listViews(session, prefix.getSchemaName());
    }

    for (SchemaTableName schemaTableName : tableNames) {
      try {
        Table table =
            metastore.getTable(schemaTableName.getSchemaName(), schemaTableName.getTableName());
        if (HiveUtil.isPrestoView(table)) {
          views.put(schemaTableName, decodeViewData(table.getViewOriginalText()));
        }
      } catch (NoSuchObjectException ignored) {
      }
    }

    return views.build();
  }
 private List<SchemaTableName> listTables(ConnectorSession session, SchemaTablePrefix prefix) {
   if (prefix.getSchemaName() == null || prefix.getTableName() == null) {
     return listTables(session, prefix.getSchemaName());
   }
   return ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));
 }
Exemple #3
0
 private List<SchemaTableName> listTables(SchemaTablePrefix prefix) {
   if (prefix.getSchemaName() == null) {
     return listTables(prefix.getSchemaName());
   }
   return ImmutableList.of(new SchemaTableName(prefix.getSchemaName(), prefix.getTableName()));
 }