SpreadsheetMetadata implements ConnectorMetadata { @Override public List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull) { if (schemaNameOrNull == null) { Map<String, Path> schemaMap = getUgi(session).doAs(new MapSchemaNames(session.getUser())); Set<String> schemaSet = new TreeSet<>(schemaMap.keySet()); Builder<SchemaTableName> builder = ImmutableList.builder(); for (String schemaName : schemaSet) { builder.addAll(listTables(session, schemaName)); } return builder.build(); } else { Path spreadsheetBasePath = getSpreadsheetBasePath(session.getUser()); Path filePath = getSpreadsheetFilePath(session, spreadsheetBasePath, schemaNameOrNull); SpreadsheetReader spreadSheetHelper = getUgi(session).doAs( new GetSpreadsheetHelper(_useFileCache, filePath, _configuration)); List<String> tableNames = spreadSheetHelper.getTableNames(); Builder<SchemaTableName> builder = ImmutableList.builder(); for (String table : tableNames) { builder.add(new SchemaTableName(schemaNameOrNull, table)); } return builder.build(); } } SpreadsheetMetadata(UserGroupInformation ugi, Configuration configuration, Path basePath,
      String spreadsheetSubDir, boolean useFileCache, boolean proxyUser); @Override List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table,
      Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns); @Override ConnectorTableLayout getTableLayout(ConnectorSession session, ConnectorTableLayoutHandle handle); @Override ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle,
      ColumnHandle columnHandle); @Override ConnectorTableMetadata getTableMetadata(ConnectorSession session, ConnectorTableHandle table); @Override Map<SchemaTableName, List<ColumnMetadata>> listTableColumns(ConnectorSession session,
      SchemaTablePrefix prefix); @Override List<String> listSchemaNames(ConnectorSession session); @Override ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName); @Override List<SchemaTableName> listTables(ConnectorSession session, String schemaNameOrNull); @Override Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle); static SpreadsheetReader getSpreadSheetHelper(UserGroupInformation ugi, ConnectorSession session,
      SpreadsheetTableHandle spreadsheetTableHandle, Configuration configuration, boolean useFileCache); static UserGroupInformation getUgi(ConnectorSession session, boolean proxyUser, UserGroupInformation ugi); static UserGroupInformation getProxyUserGroupInformation(ConnectorSession session, UserGroupInformation ugi);  }
@Test public void testListTables() throws IOException { Path basePath = setupTest(conf, SESSION.getUser(), SpreadsheetMetadataTest.class); SpreadsheetMetadata spreadsheetMetadata = new SpreadsheetMetadata(ugi, conf, basePath, SPREADSHEETS, useFileCache, true); List<SchemaTableName> listTables = spreadsheetMetadata.listTables(SESSION, SCHEMA_NAME); assertEquals(2, listTables.size()); List<String> tables = new ArrayList<String>(); for (SchemaTableName schemaTableName : listTables) { assertEquals(SCHEMA_NAME, schemaTableName.getSchemaName()); tables.add(schemaTableName.getTableName()); } Collections.sort(tables); assertEquals("multiple_types_per_column", tables.get(0)); assertEquals("simple_sheet", tables.get(1)); }