Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1981#discussion_r64709373
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/plan/logical/operators.scala
---
@@ -269,22 +269,57 @@ case class Join(
condition: Option[Expression]) extends BinaryNode {
override def output: Seq[Attribute] = {
- joinType match {
- case JoinType.INNER => left.output ++ right.output
- case j => throw new ValidationException(s"Unsupported JoinType: $j")
+ left.output ++ right.output
+ }
+
+ private case class JoinFieldReference(
+ name: String,
+ resultType: TypeInformation[_],
+ left: LogicalNode,
+ right: LogicalNode) extends Attribute {
+
+ override def toString = s"'$name"
+
+ override def toRexNode(implicit relBuilder: RelBuilder): RexNode = {
+ val joinInputField = left.output.zipWithIndex.find(_._1.name == name)
+ .orElse(
+ right.output.zipWithIndex.find(_._1.name ==
name)
+ .map(x => (x._1, left.output.length +
x._2))).get
+
+ new RexInputRef(joinInputField._2,
--- End diff --
`Expression.toRexNode()` is called in `LogicalNode.construct()`. That
means, that the input operators are on the top of the `RelBuilder` operations
stack. So we can use, `RelBuilder.field(int inputCount, int inputOrdinal,
String fieldName)` and do not have to deal with the offset computation
ourselves.
I would also do the look up of the input-local index in the constructor of
`JoinFieldReference` and add a flag that indicates whether the field is from
the left or right input. That will be helpful when validating for join
conditions.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---