flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aljos...@apache.org
Subject [2/2] flink git commit: [FLINK-1998][table] Fix equals expression
Date Fri, 08 May 2015 14:31:51 GMT
[FLINK-1998][table] Fix equals expression

The code that was generated for this used "==", now it uses .equals()


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

Branch: refs/heads/master
Commit: 84dcb7c20f5d67dbb5a931ab56e68594e491034b
Parents: 3b8f60e
Author: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Authored: Fri May 8 15:10:50 2015 +0200
Committer: Aljoscha Krettek <aljoscha.krettek@gmail.com>
Committed: Fri May 8 15:10:50 2015 +0200

----------------------------------------------------------------------
 .../api/java/table/JavaBatchTranslator.scala     |  2 +-
 .../table/codegen/ExpressionCodeGenerator.scala  |  2 +-
 .../flink/api/java/table/test/FilterITCase.java  | 19 +++++++++++++++++++
 3 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/84dcb7c2/flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
----------------------------------------------------------------------
diff --git a/flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
b/flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
index 7653ba8..24e50ef 100644
--- a/flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
+++ b/flink-staging/flink-table/src/main/scala/org/apache/flink/api/java/table/JavaBatchTranslator.scala
@@ -251,7 +251,7 @@ class JavaBatchTranslator extends PlanTranslator {
         val translatedInput = translateInternal(input)
         val inType = translatedInput.getType.asInstanceOf[CompositeType[Row]]
         val filter = new ExpressionFilterFunction[Row](predicate, inType)
-        translatedInput.filter(filter)
+        translatedInput.filter(filter).name(predicate.toString)
     }
   }
 

http://git-wip-us.apache.org/repos/asf/flink/blob/84dcb7c2/flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
----------------------------------------------------------------------
diff --git a/flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
b/flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
index fc0abe4..8cb678a 100644
--- a/flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
+++ b/flink-staging/flink-table/src/main/scala/org/apache/flink/api/table/codegen/ExpressionCodeGenerator.scala
@@ -317,7 +317,7 @@ abstract class ExpressionCodeGenerator[R](
 
       case EqualTo(left, right) =>
         generateIfNonNull(left, right, BOOLEAN_TYPE_INFO) {
-          (leftTerm, rightTerm) => s"$leftTerm == $rightTerm"
+          (leftTerm, rightTerm) => s"$leftTerm.equals($rightTerm)"
         }
 
       case NotEqualTo(left, right) =>

http://git-wip-us.apache.org/repos/asf/flink/blob/84dcb7c2/flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/FilterITCase.java
----------------------------------------------------------------------
diff --git a/flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/FilterITCase.java
b/flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/FilterITCase.java
index d40b6a0..8b5fc43 100644
--- a/flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/FilterITCase.java
+++ b/flink-staging/flink-table/src/test/java/org/apache/flink/api/java/table/test/FilterITCase.java
@@ -152,5 +152,24 @@ public class FilterITCase extends MultipleProgramsTestBase {
 				"Comment#2\n" + "10,4,Comment#4\n" + "12,5,Comment#6\n" + "14,5,Comment#8\n" + "16,6,"
+
 				"Comment#10\n" + "18,6,Comment#12\n" + "20,6,Comment#14\n";
 	}
+
+	@Test
+	public void testIntegerBiggerThan128() throws Exception {
+		ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
+		TableEnvironment tableEnv = new TableEnvironment();
+
+		DataSet<Tuple3<Integer, Long, String>> input = env.fromElements(new Tuple3<Integer,
Long, String>(300, 1L, "Hello"));
+
+		Table table = tableEnv.toTable(input, "a, b, c");
+
+		Table result = table.filter("a = 300 ");
+
+		DataSet<Row> ds = tableEnv.toSet(result, Row.class);
+		ds.writeAsText(resultPath, FileSystem.WriteMode.OVERWRITE);
+
+		env.execute();
+
+		expected = "300,1,Hello\n";
+	}
 }
 


Mime
View raw message