[ https://issues.apache.org/jira/browse/FLINK-19006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17185727#comment-17185727 ]
Aljoscha Krettek commented on FLINK-19006: ------------------------------------------ This code is more than 6 years old by now. 😅 We can fix it, but my general opinion is that we should remove these database-like or relational methods from the DataStream API. See also this thread: https://lists.apache.org/thread.html/r16bc0d1755a72e29087a97f11d26a41c35f873ef29b8fd5e0357e286%40%3Cdev.flink.apache.org%3E > project transformation does not support conversion to Tuple25 type > ------------------------------------------------------------------ > > Key: FLINK-19006 > URL: https://issues.apache.org/jira/browse/FLINK-19006 > Project: Flink > Issue Type: Improvement > Components: API / DataStream > Affects Versions: 1.11.1 > Reporter: ming li > Priority: Major > > In the {{DataStream#project}} method, it will judge whether the length of > {{fieldIndexes}} is between 1 and {{Tuple.MAX_ARITY-1}}, and then call > {{projectTupleXX}} according to the length of {{fieldIndexes}}. This limits > the maximum length of {{Tuple}} to 24. > {code:java} > protected StreamProjection(DataStream<IN> dataStream, int[] fieldIndexes) { > if (!dataStream.getType().isTupleType()) { > throw new RuntimeException("Only Tuple DataStreams can be projected"); > } > if (fieldIndexes.length == 0) { > throw new IllegalArgumentException("project() needs to select at least > one (1) field."); > } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) { > throw new IllegalArgumentException( > "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") > fields."); > } > int maxFieldIndex = (dataStream.getType()).getArity(); > for (int i = 0; i < fieldIndexes.length; i++) { > Preconditions.checkElementIndex(fieldIndexes[i], maxFieldIndex); > } > this.dataStream = dataStream; > this.fieldIndexes = fieldIndexes; > }{code} > This problem also appears in {{ProjectOperator}}. > {code:java} > public Projection(DataSet<T> ds, int[] fieldIndexes) { > if (!(ds.getType() instanceof TupleTypeInfo)) { > throw new UnsupportedOperationException("project() can only be applied > to DataSets of Tuples."); > } > if (fieldIndexes.length == 0) { > throw new IllegalArgumentException("project() needs to select at least > one (1) field."); > } else if (fieldIndexes.length > Tuple.MAX_ARITY - 1) { > throw new IllegalArgumentException( > "project() may select only up to (" + (Tuple.MAX_ARITY - 1) + ") > fields."); > } > int maxFieldIndex = ds.getType().getArity(); > for (int fieldIndexe : fieldIndexes) { > Preconditions.checkElementIndex(fieldIndexe, maxFieldIndex); > } > this.ds = ds; > this.fieldIndexes = fieldIndexes; > }{code} > I think the length we limit should be 1 to {{Tuple.MAX_ARITY}} instead of 1 > to {{Tuple.MAX_ARITY-1}}. -- This message was sent by Atlassian Jira (v8.3.4#803005)