[
https://issues.apache.org/jira/browse/FLINK-7452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16291065#comment-16291065
]
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_r156940309
--- 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
+
+ /**
+ * Returns type information for a Table API SQL time or SQL TIME type.
+ */
+ val SQL_TIME: TypeInformation[sql.Time] = JTypes.SQL_TIME
+
+ /**
+ * Returns type information for a Table API SQL timestamp or SQL
TIMESTAMP type.
+ */
+ val SQL_TIMESTAMP: TypeInformation[sql.Timestamp] = JTypes.SQL_TIMESTAMP
+
+ /**
+ * Returns type information for a Table API interval of months.
+ */
+ val INTERVAL_MONTHS: TypeInformation[lang.Integer] =
TimeIntervalTypeInfo.INTERVAL_MONTHS
+
+ /**
+ * Returns type information for a Table API interval milliseconds.
+ */
+ val INTERVAL_MILLIS: TypeInformation[lang.Long] =
TimeIntervalTypeInfo.INTERVAL_MILLIS
+
+ /**
+ * Returns type information for [[org.apache.flink.types.Row]] with
fields of the given types.
+ *
+ * A row is a variable-length, null-aware composite type for storing
multiple values in a
+ * deterministic field order. Every field can be null independent of
the field's type.
+ * The type of row fields cannot be automatically inferred; therefore,
it is required to pass
+ * type information whenever a row is used.
*
- * A row type consists of zero or more fields with a field name and a
corresponding type.
+ * <p>The schema of rows can have up to <code>Integer.MAX_VALUE</code>
fields, however, all row instances
+ * must have the same length otherwise serialization fails or
information is lost.
*
- * The fields have the default names (f0, f1, f2 ..).
+ * This method generates type information with fields of the given
types; the fields have
+ * the default names (f0, f1, f2 ..).
*
- * @param types types of row fields; e.g. Types.STRING, Types.INT
+ * @param types The types of the row fields, e.g., Types.STRING,
Types.INT
*/
@varargs
def ROW(types: TypeInformation[_]*): TypeInformation[Row] = {
JTypes.ROW(types: _*)
}
/**
- * Generates row type information.
+ * Returns type information for [[org.apache.flink.types.Row]] with
fields of the given types
+ * and with given names.
+ *
+ * A row is a variable-length, null-aware composite type for storing
multiple values in a
+ * deterministic field order. Every field can be null independent of
the field's type.
+ * The type of row fields cannot be automatically inferred; therefore,
it is required to pass
+ * type information whenever a row is used.
+ *
+ * <p>The schema of rows can have up to <code>Integer.MAX_VALUE</code>
fields, however, all row instances
--- End diff --
line exceeds 100 characters.
> 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)