private Input createInput(TableMetadata table, Optional<TableLayoutHandle> layout, Set<Column> columns) { SchemaTableName schemaTable = table.getTable(); Optional<Object> inputMetadata = layout.flatMap(tableLayout -> metadata.getInfo(session, tableLayout)); return new Input(table.getConnectorId(), schemaTable.getSchemaName(), schemaTable.getTableName(), inputMetadata, ImmutableList.copyOf(columns)); }
@Test public void testRoundTrip() { Input expected = new Input(new ConnectorId("connectorId"), "schema", "table", Optional.empty(), ImmutableList.of( new Column("column1", "string"), new Column("column2", "string"), new Column("column3", "string"))); String json = codec.toJson(expected); Input actual = codec.fromJson(json); assertEquals(actual, expected); } }
public List<Input> extract(PlanNode root) { Visitor visitor = new Visitor(); root.accept(visitor, null); ImmutableList.Builder<Input> inputBuilder = ImmutableList.builder(); for (Map.Entry<TableEntry, Set<Column>> entry : visitor.getInputs().entrySet()) { Input input = new Input(entry.getKey().getConnectorId(), entry.getKey().getSchema(), entry.getKey().getTable(), ImmutableList.copyOf(entry.getValue())); inputBuilder.add(input); } return inputBuilder.build(); }
@Test public void testRoundTrip() throws Exception { Input expected = new Input("connectorId", "schema", "table", ImmutableList.of( new Column("column1", "string"), new Column("column2", "string"), new Column("column3", "string"))); String json = codec.toJson(expected); Input actual = codec.fromJson(json); assertEquals(actual, expected); } }