(Litmus litmus, @Nullable Context context)
| 247 | } |
| 248 | |
| 249 | @Override public boolean isValid(Litmus litmus, @Nullable Context context) { |
| 250 | if (!super.isValid(litmus, context)) { |
| 251 | return litmus.fail(null); |
| 252 | } |
| 253 | if (!RexUtil.compatibleTypes(exps, getRowType(), litmus)) { |
| 254 | return litmus.fail("incompatible types"); |
| 255 | } |
| 256 | RexChecker checker = |
| 257 | new RexChecker( |
| 258 | getInput().getRowType(), context, litmus); |
| 259 | for (RexNode exp : exps) { |
| 260 | exp.accept(checker); |
| 261 | if (checker.getFailureCount() > 0) { |
| 262 | return litmus.fail("{} failures in expression {}", |
| 263 | checker.getFailureCount(), exp); |
| 264 | } |
| 265 | } |
| 266 | if (!Util.isDistinct(getRowType().getFieldNames())) { |
| 267 | return litmus.fail("field names not distinct: {}", rowType); |
| 268 | } |
| 269 | //CHECKSTYLE: IGNORE 1 |
| 270 | if (false && !Util.isDistinct(Util.transform(exps, RexNode::toString))) { |
| 271 | // Projecting the same expression twice is usually a bad idea, |
| 272 | // because it may create expressions downstream which are equivalent |
| 273 | // but which look different. We can't ban duplicate projects, |
| 274 | // because we need to allow |
| 275 | // |
| 276 | // SELECT a, b FROM c UNION SELECT x, x FROM z |
| 277 | return litmus.fail("duplicate expressions: {}", exps); |
| 278 | } |
| 279 | return litmus.succeed(); |
| 280 | } |
| 281 | |
| 282 | @Override public @Nullable RelOptCost computeSelfCost(RelOptPlanner planner, |
| 283 | RelMetadataQuery mq) { |
no test coverage detected