danny0405 commented on a change in pull request #1334: [CALCITE-3111] Allow
custom implementations of Correlate in RelDecorr…
URL: https://github.com/apache/calcite/pull/1334#discussion_r314150683
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
##########
@@ -787,10 +812,29 @@ private RelNode createValueGenerator(
assert newInput != null;
if (!joinedInputs.contains(newInput)) {
- RelNode project =
- RelOptUtil.createProject(newInput,
- mapNewInputToOutputs.get(newInput));
- RelNode distinct = relBuilder.push(project)
+ final List<Integer> positions = mapNewInputToOutputs.get(newInput);
+ final List<String> fieldNames = newInput.getRowType().getFieldNames();
+ final List<RexNode> exprs = new AbstractList<RexNode>() {
+ public int size() {
+ return positions.size();
+ }
+
+ public RexNode get(int index) {
+ final int pos = positions.get(index);
+ return relBuilder.getRexBuilder().makeInputRef(newInput, pos);
+ }
+ };
+ final List<String> names = new AbstractList<String>() {
+ public int size() {
+ return positions.size();
+ }
+
+ public String get(int index) {
+ final int pos = positions.get(index);
+ return fieldNames.get(pos);
+ }
+ };
+ RelNode distinct = relBuilder.push(newInput).projectNamed(exprs,
names, false)
Review comment:
Can we use java lambda directly for making `exprs` and `names` here ? These
`AbstractList` is not that readable.
----------------------------------------------------------------
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