Skip to content

Commit

Permalink
[FLINK-1998][table] Fix equals expression
Browse files Browse the repository at this point in the history
The code that was generated for this used "==", now it uses .equals()
  • Loading branch information
aljoscha committed May 8, 2015
1 parent 3b8f60e commit 84dcb7c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,24 @@ public void testNotEquals() throws Exception {
"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";
}
}

0 comments on commit 84dcb7c

Please sign in to comment.