You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2019/05/27 13:38:20 UTC

[flink] 02/02: [FLINK-12254][table] Improve documentation about the deprecated type system

This is an automated email from the ASF dual-hosted git repository.

twalthr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit b336b6d70d861b94995ebc9f863835fb4bc7fabb
Author: Timo Walther <tw...@apache.org>
AuthorDate: Mon May 27 11:11:01 2019 +0200

    [FLINK-12254][table] Improve documentation about the deprecated type system
    
    This closes #8510.
---
 .../org/apache/flink/table/api/TableSchema.java    | 24 ++++++++++++++++++----
 .../apache/flink/table/expressions/Expression.java |  2 +-
 .../table/expressions/TypeLiteralExpression.java   |  4 ++++
 .../flink/table/api/scala/expressionDsl.scala      |  8 ++++++--
 4 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
index c6804f9..8d6122f 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
@@ -118,7 +118,11 @@ public class TableSchema {
 	}
 
 	/**
-	 * @deprecated Use {@link #getFieldDataTypes()} instead.
+	 * @deprecated This method will be removed in future versions as it uses the old type system. It
+	 *             is recommended to use {@link #getFieldDataTypes()} instead which uses the new type
+	 *             system based on {@link DataTypes}. Please make sure to use either the old or the new
+	 *             type system consistently to avoid unintended behavior. See the website documentation
+	 *             for more information.
 	 */
 	@Deprecated
 	public TypeInformation<?>[] getFieldTypes() {
@@ -138,7 +142,11 @@ public class TableSchema {
 	}
 
 	/**
-	 * @deprecated Use {@link #getFieldDataType(int)}} instead.
+	 * @deprecated This method will be removed in future versions as it uses the old type system. It
+	 *             is recommended to use {@link #getFieldDataType(int)} instead which uses the new type
+	 *             system based on {@link DataTypes}. Please make sure to use either the old or the new
+	 *             type system consistently to avoid unintended behavior. See the website documentation
+	 *             for more information.
 	 */
 	@Deprecated
 	public Optional<TypeInformation<?>> getFieldType(int fieldIndex) {
@@ -159,7 +167,11 @@ public class TableSchema {
 	}
 
 	/**
-	 * @deprecated Use {@link #getFieldDataType(String)} instead.
+	 * @deprecated This method will be removed in future versions as it uses the old type system. It
+	 *             is recommended to use {@link #getFieldDataType(String)} instead which uses the new type
+	 *             system based on {@link DataTypes}. Please make sure to use either the old or the new
+	 *             type system consistently to avoid unintended behavior. See the website documentation
+	 *             for more information.
 	 */
 	@Deprecated
 	public Optional<TypeInformation<?>> getFieldType(String fieldName) {
@@ -306,7 +318,11 @@ public class TableSchema {
 		}
 
 		/**
-		 * @deprecated Use {@link #field(String, DataType)} instead.
+		 * @deprecated This method will be removed in future versions as it uses the old type system. It
+		 *             is recommended to use {@link #field(String, DataType)} instead which uses the new type
+		 *             system based on {@link DataTypes}. Please make sure to use either the old or the new
+		 *             type system consistently to avoid unintended behavior. See the website documentation
+		 *             for more information.
 		 */
 		@Deprecated
 		public Builder field(String name, TypeInformation<?> typeInfo) {
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/Expression.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/Expression.java
index 57c73d4..b15d692 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/Expression.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/Expression.java
@@ -30,7 +30,7 @@ import java.util.List;
  * consists of zero, one, or more sub-expressions. Expressions might be literal values, function calls,
  * or field references.
  *
- * <p>Expressions are part of the API. Thus, values and return types are expressed as instances of
+ * <p>Expressions are part of the API. Thus, value types and return types are expressed as instances of
  * {@link DataType}.
  */
 @PublicEvolving
diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/TypeLiteralExpression.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/TypeLiteralExpression.java
index f50ab00..c60c482 100644
--- a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/TypeLiteralExpression.java
+++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/expressions/TypeLiteralExpression.java
@@ -28,6 +28,10 @@ import java.util.Objects;
 
 /**
  * Expression that wraps {@link DataType} as a literal.
+ *
+ * <p>Expressing a type is primarily needed for casting operations. This expression simplifies the
+ * {@link Expression} design as it makes {@link CallExpression} the only expression that takes
+ * subexpressions.
  */
 @PublicEvolving
 public final class TypeLiteralExpression implements Expression {
diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
index 34d228f..8d77d88 100644
--- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
+++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/scala/expressionDsl.scala
@@ -22,7 +22,7 @@ import java.math.{BigDecimal => JBigDecimal}
 import java.sql.{Date, Time, Timestamp}
 
 import org.apache.flink.api.common.typeinfo.{BasicTypeInfo, SqlTimeTypeInfo, TypeInformation}
-import org.apache.flink.table.api.{Over, Table, ValidationException}
+import org.apache.flink.table.api.{DataTypes, Over, Table, ValidationException}
 import org.apache.flink.table.expressions.ApiExpressionUtils._
 import org.apache.flink.table.expressions.BuiltInFunctionDefinitions.{RANGE_TO, WITH_COLUMNS, E => FDE, UUID => FDUUID, _}
 import org.apache.flink.table.expressions._
@@ -274,7 +274,11 @@ trait ImplicitExpressionOperations {
     call(CAST, expr, typeLiteral(toType))
 
   /**
-    * @deprecated Use [[cast(DataType)]] instead.
+    * @deprecated This method will be removed in future versions as it uses the old type system. It
+    *             is recommended to use [[cast(DataType)]] instead which uses the new type system
+    *             based on [[DataTypes]]. Please make sure to use either the old or the new type
+    *             system consistently to avoid unintended behavior. See the website documentation
+    *             for more information.
     */
   @deprecated
   def cast(toType: TypeInformation[_]): Expression =