[
https://issues.apache.org/jira/browse/FLINK-7452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291079#comment-16291079
]
ASF GitHub Bot commented on FLINK-7452:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/4612#discussion_r156955846
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/Types.scala
---
@@ -25,55 +27,125 @@ import org.apache.flink.types.Row
import _root_.scala.annotation.varargs
/**
- * This class enumerates all supported types of the Table API.
+ * This class enumerates all supported types of the Table API & SQL.
*/
object Types {
- val STRING = JTypes.STRING
- val BOOLEAN = JTypes.BOOLEAN
+ /**
+ * Returns type information for a Table API string or SQL VARCHAR type.
+ */
+ val STRING: TypeInformation[String] = JTypes.STRING
+
+ /**
+ * Returns type information for a Table API boolean or SQL BOOLEAN type.
+ */
+ val BOOLEAN: TypeInformation[lang.Boolean] = JTypes.BOOLEAN
+
+ /**
+ * Returns type information for a Table API byte or SQL TINYINT type.
+ */
+ val BYTE: TypeInformation[lang.Byte] = JTypes.BYTE
+
+ /**
+ * Returns type information for a Table API short or SQL SMALLINT type.
+ */
+ val SHORT: TypeInformation[lang.Short] = JTypes.SHORT
+
+ /**
+ * Returns type information for a Table API integer or SQL INT/INTEGER
type.
+ */
+ val INT: TypeInformation[lang.Integer] = JTypes.INT
- val BYTE = JTypes.BYTE
- val SHORT = JTypes.SHORT
- val INT = JTypes.INT
- val LONG = JTypes.LONG
- val FLOAT = JTypes.FLOAT
- val DOUBLE = JTypes.DOUBLE
- val DECIMAL = JTypes.DECIMAL
+ /**
+ * Returns type information for a Table API long or SQL BIGINT type.
+ */
+ val LONG: TypeInformation[lang.Long] = JTypes.LONG
- val SQL_DATE = JTypes.SQL_DATE
- val SQL_TIME = JTypes.SQL_TIME
- val SQL_TIMESTAMP = JTypes.SQL_TIMESTAMP
- val INTERVAL_MONTHS = TimeIntervalTypeInfo.INTERVAL_MONTHS
- val INTERVAL_MILLIS = TimeIntervalTypeInfo.INTERVAL_MILLIS
+ /**
+ * Returns type information for a Table API float or SQL FLOAT/REAL
type.
+ */
+ val FLOAT: TypeInformation[lang.Float] = JTypes.FLOAT
+
+ /**
+ * Returns type information for a Table API integer or SQL DOUBLE type.
+ */
+ val DOUBLE: TypeInformation[lang.Double] = JTypes.DOUBLE
/**
- * Generates row type information.
+ * Returns type information for a Table API big decimal or SQL DECIMAL
type.
+ */
+ val DECIMAL: TypeInformation[math.BigDecimal] = JTypes.BIG_DEC
+
+ /**
+ * Returns type information for a Table API SQL date or SQL DATE type.
+ */
+ val SQL_DATE: TypeInformation[sql.Date] = JTypes.SQL_DATE
--- End diff --
The [Table API
docs](https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/table/tableApi.html#data-types)
and [SQL
docs](https://ci.apache.org/projects/flink/flink-docs-release-1.3/dev/table/sql.html#data-types)
need to be updated for `SQL_DATE`, `SQL_TIME`, and `SQL_TIMESTAMP`.
> Add helper methods for all built-in Flink types to Types
> --------------------------------------------------------
>
> Key: FLINK-7452
> URL: https://issues.apache.org/jira/browse/FLINK-7452
> Project: Flink
> Issue Type: Improvement
> Components: Type Serialization System
> Reporter: Timo Walther
> Assignee: Timo Walther
>
> Sometimes it is very difficult to provide `TypeInformation` manually, in case
> some extraction fails or is not available. {{TypeHint}}s should be the
> preferred way but this methods can ensure correct types.
> I propose to add all built-in Flink types to the {{Types}}. Such as:
> {code}
> Types.POJO(MyPojo.class)
> Types.POJO(Map<String, TypeInformation>)
> Types.GENERIC(Object.class)
> Types.TUPLE(TypeInformation, ...)
> Types.MAP(TypeInformation, TypeInformation)
> {code}
> The methods should validate that the returned type is exactly the requested
> type. And especially in case of POJO should help creating {{PojoTypeInfo}}.
> Once this is in place, we can deprecate the {{TypeInfoParser}}.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)