@Test public void testCatalogTable() throws TableAlreadyExistException, DatabaseNotExistException { GenericInMemoryCatalog catalog = new GenericInMemoryCatalog(catalogName, databaseName); DatabaseCalciteSchema calciteSchema = new DatabaseCalciteSchema(true, databaseName, catalogName, catalog); catalog.createTable(new ObjectPath(databaseName, tableName), new TestCatalogBaseTable(), false); Table table = calciteSchema.getTable(tableName); assertThat(table, instanceOf(TableSourceTable.class)); TableSourceTable tableSourceTable = (TableSourceTable) table; assertThat(tableSourceTable.tableSource(), instanceOf(TestExternalTableSource.class)); assertThat(tableSourceTable.isStreamingMode(), is(true)); }
@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) { throw new TableException(format( "A failure occurred when accessing table. Table path [%s, %s, %s]", catalogName, databaseName, tableName), e); } }
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) { throw new TableException(format( "A failure occurred when accessing table. Table path [%s, %s, %s]", catalogName, databaseName, tableName), e); } } }
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) { throw new TableException(format( "A failure occurred when accessing table. Table path [%s, %s, %s]", catalogName, databaseName, tableName), e); } } DatabaseCalciteSchema(
			boolean isStreamingMode,
			String databaseName,
			String catalogName,
			Catalog catalog); }
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) { throw new TableException(format( "A failure occurred when accessing table. Table path [%s, %s, %s]", catalogName, databaseName, tableName), e); } } DatabaseCalciteSchema(
			boolean isStreamingMode,
			String databaseName,
			String catalogName,
			Catalog catalog); @Override Table getTable(String tableName); @Override Set<String> getTableNames(); @Override RelProtoDataType getType(String name); @Override Set<String> getTypeNames(); @Override Collection<Function> getFunctions(String s); @Override Set<String> getFunctionNames(); @Override Schema getSubSchema(String s); @Override Set<String> getSubSchemaNames(); @Override Expression getExpression(SchemaPlus parentSchema, String name); @Override boolean isMutable(); @Override Schema snapshot(SchemaVersion schemaVersion); }
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) { throw new TableException(format( "A failure occurred when accessing table. Table path [%s, %s, %s]", catalogName, databaseName, tableName), e); } } DatabaseCalciteSchema(
			boolean isStreamingMode,
			String databaseName,
			String catalogName,
			Catalog catalog); @Override Table getTable(String tableName); @Override Set<String> getTableNames(); @Override RelProtoDataType getType(String name); @Override Set<String> getTypeNames(); @Override Collection<Function> getFunctions(String s); @Override Set<String> getFunctionNames(); @Override Schema getSubSchema(String s); @Override Set<String> getSubSchemaNames(); @Override Expression getExpression(SchemaPlus parentSchema, String name); @Override boolean isMutable(); @Override Schema snapshot(SchemaVersion schemaVersion);  }