@SuppressWarnings("unchecked") private Map<String, BeamSqlTable> toTableMap(PInput inputs) { /** * A single PCollection is transformed to a table named PCOLLECTION, other input types are * expanded and converted to tables using the tags as names. */ if (inputs instanceof PCollection) { PCollection<?> pCollection = (PCollection<?>) inputs; return ImmutableMap.of(PCOLLECTION_NAME, new BeamPCollectionTable(pCollection)); } ImmutableMap.Builder<String, BeamSqlTable> tables = ImmutableMap.builder(); for (Map.Entry<TupleTag<?>, PValue> input : inputs.expand().entrySet()) { PCollection<?> pCollection = (PCollection<?>) input.getValue(); tables.put(input.getKey().getId(), new BeamPCollectionTable(pCollection)); } return tables.build(); }
/** * Creates a new Node with the given parent and transform. * * @param enclosingNode the composite node containing this node * @param transform the PTransform tracked by this node * @param fullName the fully qualified name of the transform * @param input the unexpanded input to the transform */ private Node(Node enclosingNode, PTransform<?, ?> transform, String fullName, PInput input) { this.enclosingNode = enclosingNode; this.transform = transform; this.fullName = fullName; ImmutableMap.Builder<TupleTag<?>, PValue> inputs = ImmutableMap.builder(); inputs.putAll(input.expand()); inputs.putAll(transform.getAdditionalInputs()); this.inputs = inputs.build(); }