vlsi commented on a change in pull request #2613:
URL: https://github.com/apache/calcite/pull/2613#discussion_r764919901



##########
File path: core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
##########
@@ -2482,6 +2497,37 @@ private void checkPredicates(RelOptCluster cluster, 
RelOptTable empTable,
     assertThat(inputRef1.getIdentifier(), is(inputRef2.getIdentifier()));
   }
 
+  @Test void testExpressionLineageConjuntiveExpression() {
+    String sql = "select (empno = 1 or ename = 'abc') and deptno > 1 from emp";
+    String expected = "[AND(OR(=([CATALOG, SALES, EMP].#0.$0, 1), "
+        + "=([CATALOG, SALES, EMP].#0.$1, 'abc')), "
+        + ">([CATALOG, SALES, EMP].#0.$7, 1))]";
+
+    BiFunction<RexNode, RelNode, String> supplier = (ref, rel) -> "Lineage for 
expr '"
+        + ref + "' in node '" + rel + "'" + " for query '" + sql + "':\n"
+        + "'empno' is column 0 in 'catalog.sales.emp', "
+        + "'ename' is column 1 in 'catalog.sales.emp', and "
+        + "'deptno' is column 7 in 'catalog.sales.emp'";
+
+    assertExpressionLineage(sql, 0, expected, supplier);
+  }
+
+  @Test void testExpressionLineageBetweenExpressionWithJoin() {
+    String sql = "select dept.deptno + empno between 1 and 2"
+        + " from emp join dept on emp.deptno = dept.deptno";
+    String expected = "[AND(>=(+([CATALOG, SALES, DEPT].#0.$0, [CATALOG, 
SALES, EMP].#0.$0), 1),"
+        + " <=(+([CATALOG, SALES, DEPT].#0.$0, [CATALOG, SALES, EMP].#0.$0), 
2))]";
+
+    BiFunction<RexNode, RelNode, String> supplier = (ref, rel) -> "Lineage for 
expr '"
+        + ref + "' in node '" + rel + "'" + " for query '" + sql + "':\n"

Review comment:
       Ah, it looks like `BiFunction` and `Supplier` is not really needed here. 
Just `String comment` argument is enough for `assertExpressionLineage`, and 
`assertExpressionLineage` can add the prefix with ref, rel, and sql.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to