MCPcopy Create free account
hub / github.com/apache/calcite / isValid

Method isValid

core/src/main/java/org/apache/calcite/rel/core/Project.java:249–280  ·  view source on GitHub ↗
(Litmus litmus, @Nullable Context context)

Source from the content-addressed store, hash-verified

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) {

Callers 1

ProjectMethod · 0.95

Calls 11

compatibleTypesMethod · 0.95
getFailureCountMethod · 0.95
isDistinctMethod · 0.95
transformMethod · 0.95
succeedMethod · 0.80
isValidMethod · 0.65
failMethod · 0.65
getRowTypeMethod · 0.65
getInputMethod · 0.65
acceptMethod · 0.65
getFieldNamesMethod · 0.65

Tested by

no test coverage detected