Source:
<code>@Test void testCalcWithHints() { final RelHint calcHint = RelHint.builder("resource").build(); final RelBuilder builder = RelBuilder.create(config().build()); builder.getCluster().setHintStrategies( HintStrategyTable.builder().hintStrategy("resource", HintPredicates.CALC).build()); final RelNode original = builder.scan("EMP") .project( builder.field("EMPNO"), builder.field("ENAME"), builder.field("DEPTNO") ).hints(calcHint) .sort(builder.field("EMPNO")) .project(builder.field("EMPNO")) .build(); final HepProgram hepProgram = new HepProgramBuilder() .addRuleInstance(ProjectToCalcRule.INSTANCE) .build(); final HepPlanner hepPlanner = new HepPlanner(hepProgram); hepPlanner.setRoot(original); final RelNode relNode = hepPlanner.findBestExp(); final RelFieldTrimmer fieldTrimmer = new RelFieldTrimmer(null, builder); final RelNode trimmed = fieldTrimmer.trim(relNode); final String expected = "" + "LogicalCalc(expr#0=[{inputs}], EMPNO=[$t0])\n" + " LogicalSort(sort0=[$0], dir0=[ASC])\n" + " LogicalCalc(expr#0=[{inputs}], EMPNO=[$t0])\n" + " LogicalProject(EMPNO=[$0])\n" + " LogicalTableScan(table=[[scott, EMP]])\n"; assertThat(trimmed, hasTree(expected)); <START> assertTrue(original.getInput(0).getInput(0) instanceof Project); <END> final Project originalProject = (Project) original.getInput(0).getInput(0); assertTrue(originalProject.getHints().contains(calcHint)); assertTrue(trimmed.getInput(0).getInput(0) instanceof Calc); final Calc calc = (Calc) trimmed.getInput(0).getInput(0); assertTrue(calc.getHints().contains(calcHint)); }</code><technical_language>minor: I in this test sense verify original Calc (relNode.getInput(0).getInput(0)) contains hints</technical_language>

Target:
@Test void testCalcWithHints() { final RelHint calcHint = RelHint.builder("resource").build(); final RelBuilder builder = RelBuilder.create(config().build()); builder.getCluster().setHintStrategies( HintStrategyTable.builder().hintStrategy("resource", HintPredicates.CALC).build()); final RelNode original = builder.scan("EMP") .project( builder.field("EMPNO"), builder.field("ENAME"), builder.field("DEPTNO") ).hints(calcHint) .sort(builder.field("EMPNO")) .project(builder.field("EMPNO")) .build(); final HepProgram hepProgram = new HepProgramBuilder() .addRuleInstance(ProjectToCalcRule.INSTANCE) .build(); final HepPlanner hepPlanner = new HepPlanner(hepProgram); hepPlanner.setRoot(original); final RelNode relNode = hepPlanner.findBestExp(); final RelFieldTrimmer fieldTrimmer = new RelFieldTrimmer(null, builder); final RelNode trimmed = fieldTrimmer.trim(relNode); final String expected = "" + "LogicalCalc(expr#0=[{inputs}], EMPNO=[$t0])\n" + " LogicalSort(sort0=[$0], dir0=[ASC])\n" + " LogicalCalc(expr#0=[{inputs}], EMPNO=[$t0])\n" + " LogicalProject(EMPNO=[$0])\n" + " LogicalTableScan(table=[[scott, EMP]])\n"; assertThat(trimmed, hasTree(expected)); assertTrue(original.getInput(0).getInput(0) instanceof Project); final Project originalProject = (Project) original.getInput(0).getInput(0); assertTrue(originalProject.getHints().contains(calcHint)); assertTrue(relNode.getInput(0).getInput(0) instanceof Calc); final Calc originalCalc = (Calc) relNode.getInput(0).getInput(0); assertTrue(originalCalc.getHints().contains(calcHint)); assertTrue(trimmed.getInput(0).getInput(0) instanceof Calc); final Calc calc = (Calc) trimmed.getInput(0).getInput(0); assertTrue(calc.getHints().contains(calcHint)); }