Dian Fu created FLINK-40187:
-------------------------------

             Summary: Introduce DataType class in DataFrame API
                 Key: FLINK-40187
                 URL: https://issues.apache.org/jira/browse/FLINK-40187
             Project: Flink
          Issue Type: Sub-task
          Components: API / Python
            Reporter: Dian Fu
            Assignee: Liu Liu
             Fix For: 2.4.0


It may look like the following:

{code:python}
class DataType:
    # Numeric types
    @classmethod def int8(cls) -> DataType          # TINYINT
    @classmethod def int16(cls) -> DataType         # SMALLINT
    @classmethod def int32(cls) -> DataType         # INT
    @classmethod def int64(cls) -> DataType         # BIGINT
    @classmethod def float32(cls) -> DataType       # FLOAT
    @classmethod def float64(cls) -> DataType       # DOUBLE
    @classmethod def decimal(cls, precision: int, scale: int) -> DataType

    # String/Binary types
    @classmethod def string(cls) -> DataType                         # VARCHAR
    @classmethod def fixed_size_string(cls, length: int) -> DataType # CHAR(n)
    @classmethod def binary(cls) -> DataType                         # BYTES
    @classmethod def fixed_size_binary(cls, length: int) -> DataType # BINARY(n)

    # Boolean & Null
    @classmethod def bool(cls) -> DataType          # BOOLEAN
    @classmethod def null(cls) -> DataType          # NULL

    # Temporal types
    @classmethod def date(cls) -> DataType
    @classmethod def time(cls, precision: int = 0) -> DataType
    @classmethod def timestamp(cls, precision: int = 6) -> DataType
    @classmethod def timestamp_ltz(cls, precision: int = 6) -> DataType

    # Complex types
    @classmethod def list(cls, dtype: DataType) -> DataType
    @classmethod def map(cls, key_type: DataType, value_type: DataType) -> 
DataType
    @classmethod def struct(cls, fields: Union[Dict[str, DataType], 
List[tuple]]) -> DataType

    # Modifiers
    def not_null(self) -> DataType
    def nullable(self) -> DataType
{code}




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to