[FLINK-40187][python] Introduce DataType class in DataFrame API - #28843
Conversation
f840c98 to
ff4525b
Compare
Generated-by: OpenAI Codex (GPT-5.6 Sol)
ff4525b to
d8682e9
Compare
|
|
||
| DataType | ||
| DataType.not_null | ||
| DataType.nullable |
There was a problem hiding this comment.
What about moving these two APIs to the end of this list?
There was a problem hiding this comment.
I moved these null markers to the end of the list.
| """ | ||
| Create a list type. | ||
|
|
||
| :param dtype: Type of each list element. |
There was a problem hiding this comment.
It would be great to add an example.
| Create a map type. | ||
|
|
||
| :param key_type: Type of each map key. | ||
| :param value_type: Type of each map value. |
There was a problem hiding this comment.
ditto, it would be great to add an example.
| >>> import pyflink.dataframe as pf | ||
| >>> person_type = pf.DataType.struct({ | ||
| ... "name": pf.DataType.string(), | ||
| ... "age": pf.DataType.int32(), |
There was a problem hiding this comment.
Also add an example when the type of fields is an list.
|
|
||
| @classmethod | ||
| @PublicEvolving() | ||
| def int8(cls) -> "DataType": |
There was a problem hiding this comment.
pf.lit(1, DataType.int8()), int16(), and float32() raise Java ValidationExceptions because Py4J sends Integer/Double rather than Byte/Short/Float. Date/time/timestamp, list, and struct literals fail similarly. Extend the literal conversion path for these types and add end-to-end factory/literal tests.
There was a problem hiding this comment.
Good catch! The root cause for this is an existing flaw in the Table API's lit method, which fails to adapt some types for Py4J. I think it's worth a separate PR, where we fix it cleanly in the Table API layer.
There was a problem hiding this comment.
Sure. Could you create a JIRA ticket?
There was a problem hiding this comment.
Created at FLINK-40300. I'll be working on a PR soon.
Move DataType.not_null and DataType.nullable to the end of the autosummary list in the RST reference, and add usage examples to the DataType.list, DataType.map, and DataType.struct docstrings (including the list-of-tuples form for struct). Generated-by: OpenCode (GLM-5.2-FP8)
9af8b75 to
7d1396d
Compare
What is the purpose of the change
This pull request completes the
DataTypeAPI for the PyFlink DataFrame API. It provides the scalar, temporal, and composite data types required by subsequent DataFrame operations.Brief change log
DataTypefactory methods.DataType.NULLwhen converting Java data types to Python data types.Verifying this change
This change added tests and can be verified as follows:
.venv/bin/python -m pytest -q flink-python/pyflink/dataframe/tests94 passedpy_compile.mvn -T 12 spotless:checkthrough the pre-push hook.Does this pull request potentially affect one of the following parts:
@Public(Evolving): yesDocumentation
Was generative AI tooling used to co-author this PR?
Generated-by: OpenAI Codex (GPT-5.6 Sol)