Mika Naylor created FLINK-37625: ----------------------------------- Summary: PyFlink Table API skips validation for Rows created with positional arguments Key: FLINK-37625 URL: https://issues.apache.org/jira/browse/FLINK-37625 Project: Flink Issue Type: Bug Components: API / Python Reporter: Mika Naylor Assignee: Mika Naylor
When creating a table using {{{}TableEnvironment.from_elements{}}}, the Table API skips type validation on any Row elements that were created using positional arguments, rather than keyword arguments. For example, take a table with a single column, whose type is an array of {{{}Row{}}}s. These rows have 2 columns, {{a VARCHAR}} and {{{}b BOOLEAN{}}}. If we create a table with elements where one of these rows has columns in the wrong order: {code:java} schema = DataTypes.ROW( [ DataTypes.FIELD( "col", DataTypes.ARRAY( DataTypes.ROW( [ DataTypes.FIELD("a", DataTypes.STRING()), DataTypes.FIELD("b", DataTypes.BOOLEAN()), ] ) ), ), ] ) elements = [( [("pyflink", True), ("pyflink", False), (True, "pyflink")], )] table = self.t_env.from_elements(elements, schema) table_result = list(table.execute().collect()){code} This results in a type validation error: {code:java} TypeError: field a in element in array field col: VARCHAR can not accept object True in type <class 'bool'>{code} In an example where we use {{Row}} instead of tuples, but with column arguments: {code:java} elements = [( [Row(a="pyflink", b=True), Row(a="pyflink", b=False), Row(a=True, b="pyflink")], )]{code} We also get the same type validation error. However, when we use {{Row}} with positional arguments: {code:java} elements = [( [Row("pyflink", True), Row("pyflink", False), Row(True, "pyflink")], )]{code} the type validation is skipped, leading to an unpickling error when collecting: {code:java} > data = pickle.loads(data) E EOFError: Ran out of input {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)