jinxing64 commented on a change in pull request #1454: [CALCITE-3348]
AssertionError while determining distribution of Calc
URL: https://github.com/apache/calcite/pull/1454#discussion_r324520914
##########
File path: core/src/main/java/org/apache/calcite/rex/RexProgram.java
##########
@@ -821,6 +824,29 @@ public RexProgram normalize(RexBuilder rexBuilder,
boolean simplify) {
: null);
}
+ /**
+ * Returns a partial mapping of a set of project expressions.
+ *
+ * <p>The mapping is an inverse function.
+ * Every target has a source field, but
+ * a source might have 0, 1 or more targets.
+ * Project expressions that do not consist of
+ * a mapping are ignored.
+ *
+ * @param inputFieldCount Number of input fields
+ * @return Mapping of a set of project expressions, never null
+ */
+ public Mappings.TargetMapping getPartialMapping(int inputFieldCount) {
+ Mappings.TargetMapping mapping =
+ Mappings.create(MappingType.INVERSE_FUNCTION,
+ inputFieldCount, projects.size());
+ for (Ord<RexLocalRef> exp : Ord.zip(projects)) {
+ RexInputRef inputRef = (RexInputRef) exprs.get(exp.e.index);
Review comment:
Shall we call `RexProgram#expandLocalRef` for the expansion ?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services