flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twal...@apache.org
Subject flink git commit: [FLINK-4242] [table] Improve validation exception messages
Date Thu, 11 Aug 2016 12:22:32 GMT
Repository: flink
Updated Branches:
  refs/heads/master c2a404386 -> 8ccee48c5


[FLINK-4242] [table] Improve validation exception messages

This closes #2290.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/8ccee48c
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/8ccee48c
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/8ccee48c

Branch: refs/heads/master
Commit: 8ccee48c590e9e094a76d5b268344d258a4438cf
Parents: c2a4043
Author: gallenvara <gallenvara@126.com>
Authored: Sat Jul 23 23:59:01 2016 +0800
Committer: twalthr <twalthr@apache.org>
Committed: Thu Aug 11 14:16:26 2016 +0200

----------------------------------------------------------------------
 .../api/table/expressions/arithmetic.scala      |  6 +++---
 .../flink/api/table/expressions/logic.scala     |  8 ++++----
 .../table/expressions/stringExpressions.scala   | 20 ++++++++++++--------
 .../api/table/plan/logical/operators.scala      |  9 +++++----
 4 files changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/8ccee48c/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/arithmetic.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/arithmetic.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/arithmetic.scala
index e17a011..e4ed08e 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/arithmetic.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/arithmetic.scala
@@ -45,8 +45,8 @@ abstract class BinaryArithmetic extends BinaryExpression {
   // TODO: tighten this rule once we implemented type coercion rules during validation
   override private[flink] def validateInput(): ExprValidationResult = {
     if (!isNumeric(left.resultType) || !isNumeric(right.resultType)) {
-      ValidationFailure(s"$this requires both operands Numeric, got " +
-        s"${left.resultType} and ${right.resultType}")
+      ValidationFailure(s"$this requires both operands Numeric, get " +
+        s"$left : ${left.resultType} and $right : ${right.resultType}")
     } else {
       ValidationSuccess
     }
@@ -78,7 +78,7 @@ case class Plus(left: Expression, right: Expression) extends BinaryArithmetic
{
       ValidationSuccess
     } else if (!isNumeric(left.resultType) || !isNumeric(right.resultType)) {
       ValidationFailure(s"$this requires Numeric or String input," +
-        s" get ${left.resultType} and ${right.resultType}")
+        s" get $left : ${left.resultType} and $right : ${right.resultType}")
     } else {
       ValidationSuccess
     }

http://git-wip-us.apache.org/repos/asf/flink/blob/8ccee48c/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/logic.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/logic.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/logic.scala
index 3282643..bf4dc85 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/logic.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/logic.scala
@@ -32,8 +32,8 @@ abstract class BinaryPredicate extends BinaryExpression {
         right.resultType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"$this only accepts children of Boolean Type, " +
-        s"get ${left.resultType} and ${right.resultType}")
+      ValidationFailure(s"$this only accepts children of Boolean type, " +
+        s"get $left : ${left.resultType} and $right : ${right.resultType}")
     }
   }
 }
@@ -52,8 +52,8 @@ case class Not(child: Expression) extends UnaryExpression {
     if (child.resultType == BasicTypeInfo.BOOLEAN_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"Not only accepts child of Boolean Type, " +
-        s"get ${child.resultType}")
+      ValidationFailure(s"Not operator requires a boolean expression as input, " +
+        s"but $child is of type ${child.resultType}")
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/8ccee48c/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/stringExpressions.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/stringExpressions.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/stringExpressions.scala
index 047a35a..597ff12 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/stringExpressions.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/expressions/stringExpressions.scala
@@ -37,7 +37,8 @@ case class CharLength(child: Expression) extends UnaryExpression {
     if (child.resultType == STRING_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"CharLength only accepts String input, get ${child.resultType}")
+      ValidationFailure(s"CharLength operator requires String input, " +
+        s"but $child is of type ${child.resultType}")
     }
   }
 
@@ -59,7 +60,8 @@ case class InitCap(child: Expression) extends UnaryExpression {
     if (child.resultType == STRING_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"InitCap only accepts String input, get ${child.resultType}")
+      ValidationFailure(s"InitCap operator requires String input, " + 
+        s"but $child is of type ${child.resultType}")
     }
   }
 
@@ -83,8 +85,8 @@ case class Like(str: Expression, pattern: Expression) extends BinaryExpression
{
     if (str.resultType == STRING_TYPE_INFO && pattern.resultType == STRING_TYPE_INFO)
{
       ValidationSuccess
     } else {
-      ValidationFailure(s"Like only accepts (String, String) input, " +
-        s"get (${str.resultType}, ${pattern.resultType})")
+      ValidationFailure(s"Like operator requires (String, String) input, " +
+        s"but ($str, $pattern) is of type (${str.resultType}, ${pattern.resultType})")
     }
   }
 
@@ -105,7 +107,8 @@ case class Lower(child: Expression) extends UnaryExpression {
     if (child.resultType == STRING_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"Lower only accepts String input, get ${child.resultType}")
+      ValidationFailure(s"Lower operator requires String input, " +
+        s"but $child is of type ${child.resultType}")
     }
   }
 
@@ -129,8 +132,8 @@ case class Similar(str: Expression, pattern: Expression) extends BinaryExpressio
     if (str.resultType == STRING_TYPE_INFO && pattern.resultType == STRING_TYPE_INFO)
{
       ValidationSuccess
     } else {
-      ValidationFailure(s"Similar only accepts (String, String) input, " +
-        s"get (${str.resultType}, ${pattern.resultType})")
+      ValidationFailure(s"Similar operator requires (String, String) input, " +
+        s"but ($str, $pattern) is of type (${str.resultType}, ${pattern.resultType})")
     }
   }
 
@@ -208,7 +211,8 @@ case class Upper(child: Expression) extends UnaryExpression {
     if (child.resultType == STRING_TYPE_INFO) {
       ValidationSuccess
     } else {
-      ValidationFailure(s"Upper only accepts String input, get ${child.resultType}")
+      ValidationFailure(s"Upper operator requires String input, " +
+        s"but $child is of type ${child.resultType}")
     }
   }
 

http://git-wip-us.apache.org/repos/asf/flink/blob/8ccee48c/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
index 48da6c5..c33efd0 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
@@ -184,8 +184,8 @@ case class Filter(condition: Expression, child: LogicalNode) extends UnaryNode
{
   override def validate(tableEnv: TableEnvironment): LogicalNode = {
     val resolvedFilter = super.validate(tableEnv).asInstanceOf[Filter]
     if (resolvedFilter.condition.resultType != BOOLEAN_TYPE_INFO) {
-      failValidation(s"filter expression ${resolvedFilter.condition} of" +
-        s" ${resolvedFilter.condition.resultType} is not a boolean")
+      failValidation(s"Filter operator requires a boolean expression as input," +
+        s" but ${resolvedFilter.condition} is of type ${resolvedFilter.condition.resultType}")
     }
     resolvedFilter
   }
@@ -248,7 +248,7 @@ case class Aggregate(
       if (!expr.resultType.isKeyType) {
         failValidation(
           s"expression $expr cannot be used as a grouping expression " +
-            "because it's not a valid key type")
+            "because it's not a valid key type which must be hashable and comparable")
       }
     }
     resolvedAggregate
@@ -424,7 +424,8 @@ case class Join(
 
     val resolvedJoin = super.validate(tableEnv).asInstanceOf[Join]
     if (!resolvedJoin.condition.forall(_.resultType == BOOLEAN_TYPE_INFO)) {
-      failValidation(s"filter expression ${resolvedJoin.condition} is not a boolean")
+      failValidation(s"Filter operator requires a boolean expression as input, " + 
+        s"but ${resolvedJoin.condition} is of type ${resolvedJoin.joinType}")
     } else if (ambiguousName.nonEmpty) {
       failValidation(s"join relations with ambiguous names: ${ambiguousName.mkString(", ")}")
     }


Mime
View raw message