Skip to content

fix(python): render field types as SQL strings, not Rust Debug - #786

Open
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/data-type-sql-string
Open

fix(python): render field types as SQL strings, not Rust Debug#786
jackylee-ch wants to merge 1 commit into
apache:mainfrom
jackylee-ch:fix/data-type-sql-string

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

PyDataField.field_type() returns Rust Debug output — a column declared
VARCHAR(10) reads back as Varchar(VarCharType { length: 10, nullable: true }).
The in-place TODO(#284 follow-up) names the cause: DataType has no enum-level
Display, so there was nothing to call.

Only 10 of the 23 variants carried a leaf Display. This adds the other nine
scalars and the four constructed types, then the dispatch. The constructed formats
fill Java's FORMAT with the children's own SQL strings (ARRAY<%s>,
MAP<%s, %s>, MULTISET<%s>, ROW<%s>), so a child's NOT NULL sits inside the
brackets and the outer one after them; ROW renders fields like
DataField.asSQLString — escaped name, type, then COMMENT '...'. Every keyword
and format string was checked against the Java class rather than inferred.

The dispatch also retires VectorType::element_sql_name, a private table of seven
primitive names with unreachable!() for the rest, which existed only because this
dispatch did not.

cargo test -p pypaimon_rust cannot link libpython here, so the binding is
compile-checked locally and its behaviour left to integration (python).
The rendering is covered by unit tests in paimon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant