SpreadsheetMetadata implements ConnectorMetadata { @Override public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName) { Path spreadsheetPath = getSpreadsheetBasePath(session.getUser()); Path filePath = getSpreadsheetFilePath(session, spreadsheetPath, tableName.getSchemaName()); return new SpreadsheetTableHandle(session.getUser(), tableName, filePath.toString()); } 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 testGetTableHandle() 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); for (SchemaTableName name : listTables) { ConnectorTableHandle tableHandle = spreadsheetMetadata.getTableHandle(SESSION, name); assertTrue(tableHandle instanceof SpreadsheetTableHandle); SpreadsheetTableHandle spreadsheetTableHandle = (SpreadsheetTableHandle) tableHandle; String filePath = new Path(new Path(new Path(basePath, SESSION.getUser()), SPREADSHEETS), PRESTO_EXAMPLE_XLSX).toString(); assertEquals(filePath, spreadsheetTableHandle.getSpreadsheetPath()); SchemaTableName tableName = spreadsheetTableHandle.getTableName(); assertEquals(name, tableName); assertEquals(SESSION.getUser(), spreadsheetTableHandle.getUser()); } }