vlsi commented on a change in pull request #2613:
URL: https://github.com/apache/calcite/pull/2613#discussion_r764773927
##########
File path: core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
##########
@@ -2483,38 +2484,43 @@ private void checkPredicates(RelOptCluster cluster,
RelOptTable empTable,
}
@Test void testExpressionLineageConjuntiveExpression() {
- // empno is column 0 in catalog.sales.emp
- // ename is column 1 in catalog.sales.emp
- // deptno is column 7 in catalog.sales.emp
- final RelNode rel = convertSql("select (empno = 1 or ename = 'abc') and
deptno > 1 from emp");
+ final String sql = "select (empno = 1 or ename = 'abc') and deptno > 1
from emp";
+ final RelNode rel = convertSql(sql);
final RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
final RexNode ref = RexInputRef.of(0, rel.getRowType().getFieldList());
- final Set<RexNode> r = mq.getExpressionLineage(rel, ref);
- assertThat(r.size(), is(1));
+ final Set<RexNode> r = Objects.requireNonNull(mq.getExpressionLineage(rel,
ref));
Review comment:
The motivation is exactly the same: test failure should include
meaningful information.
If you add `requireNonNull`, `getOnlyElement`, etc, etc, then you make it
harder to understand the nature of the failure.
This case is trivial: the test expects a set with a single element. The
assertion message is more or less OK.
Why adding more checks before the final `assertEquals`?
I believe, the final `assertEquals` should be more than enough to tell that
"expected ... got null".
--
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]