class DatabaseCalciteSchema implements Schema {

	@Override
	public Table getTable(String tableName) {

		ObjectPath tablePath = new ObjectPath(databaseName, tableName);

		try {
			if (!catalog.tableExists(tablePath)) {
				return null;
			}

			CatalogBaseTable table = catalog.getTable(tablePath);

			if (table instanceof QueryOperationCatalogView) {
				return QueryOperationCatalogViewTable.createCalciteTable(((QueryOperationCatalogView) table));
			} else if (table instanceof ConnectorCatalogTable) {
				return convertConnectorTable((ConnectorCatalogTable<?, ?>) table);
			} else if (table instanceof CatalogTable) {
				return convertCatalogTable(tablePath, (CatalogTable) table);
			} else {
				throw new TableException("Unsupported table type: " + table);
			}
		} catch (TableNotExistException | CatalogException e) {
			// TableNotExistException should never happen, because we are checking it exists
			// via catalog.tableExists
			throw new TableException(format(
				"A failure occurred when accessing table. Table path [%s, %s, %s]",
				catalogName,
				databaseName,
				tableName), e);
		}
	}

	public  DatabaseCalciteSchema(
			boolean isStreamingMode,
			String databaseName,
			String catalogName,
			Catalog catalog);

}