twalthr opened a new pull request #10342: [FLINK-14967][table] Add a utility for creating data types via reflection URL: https://github.com/apache/flink/pull/10342 ## What is the purpose of the change This implements the data type extractor mentioned in FLIP-65. It is similar to Flink's core type information extractor but also adds a lot of SQL specific features and improves the overall user experience. In particular, it allows to annotate types, fields, and classes for parameterizing the extraction process. It is unified across Java and Scala. The following description is copied from `DataTypeHint`: ``` /** * A hint that influences the reflection-based extraction of a {@link DataType}. * * <p>Data type hints can parameterize or replace the default extraction logic of individual function parameters * and return types, structured classes, or fields of structured classes. An implementer can choose to * what extent the default extraction logic should be modified. * * <p>The following examples show how to explicitly specify data types, how to parameterize the extraction * logic, or how to accept any data type as an input data type: * * <p>{@code @DataTypeHint("INT")} defines an INT data type with a default conversion class. * * <p>{@code @DataTypeHint(value = "TIMESTAMP(3)", bridgedTo = java.sql.Timestamp.class)} defines a TIMESTAMP * data type of millisecond precision with an explicit conversion class. * * <p>{@code @DataTypeHint(value = "RAW", rawSerializer = MyCustomSerializer.class)} defines a RAW data type * with a custom serializer class. * * <p>{@code @DataTypeHint(version = V1, allowRawGlobally = TRUE)} parameterizes the extraction by requesting * a extraction logic version of 1 and allowing the RAW data type in this structured type (and possibly * nested fields). * * <p>{@code @DataTypeHint(bridgedTo = MyPojo.class, allowRawGlobally = TRUE)} defines that a type should be * extracted from the given conversion class but with parameterized extraction for allowing RAW types. * * <p>{@code @DataTypeHint(inputGroup = ANY)} defines that the input validation should accept any * data type. * * <p>Note: All hint parameters are optional. Hint parameters defined on top of a structured type are * inherited by all (deeply) nested fields unless annotated differently. For example, all occurrences of * {@link java.math.BigDecimal} will be extracted as {@code DECIMAL(12, 2)} if the enclosing structured * class is annotated with {@code @DataTypeHint(defaultDecimalPrecision = 12, defaultDecimalScale = 2)}. Individual * field annotations allow to deviate from those default values. */ ``` ## Brief change log - Data type hint annotation added - Data type extractor added ## Verifying this change This change added tests and can be verified as follows: `DataTypeExtractorTest` and `DataTypeExtractorScalaTest` ## Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): yes - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no - The serializers: no - The runtime per-record code paths (performance sensitive): no - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no - The S3 file system connector: no ## Documentation - Does this pull request introduce a new feature? yes - If yes, how is the feature documented? JavaDocs
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
