mspruc commented on issue #545:
URL: https://github.com/apache/wayang/issues/545#issuecomment-3949887108
@makarandhinge Multi condition refers to joins where we have additional
columns projected typically in `JOIN x.1 = y.1 AND x.2 = y.2`. How we approach
the SQL generation remains an open issue.
For some of the `Visitor`s I use `CallTreeFactory` to generate a Wayang side
representation of Calcites call trees. Maybe you can use some sort of pattern
like that to dynamically generate SQL?
Just be aware that the `JdbcExecutor` calls `createSqlClause()` on the given
operator, and the SQL statement needs to satisfy the pattern:
``` @Override
public String createSqlClause(Connection connection, FunctionCompiler
compiler) {
final Tuple<String, String> left =
this.keyDescriptor0.getSqlImplementation();
final Tuple<String, String> right =
this.keyDescriptor1.getSqlImplementation();
// LHS of join condition:
final String leftTableName = left.field0.strip();
final String leftKey = left.field1.strip();
// RHS of join condition
final String rightTableName = right.field0.strip();
final String rightKey = right.field1.strip();
// TODO: this aliasing should be handled more smoothly mb it could
be a field?
if (leftTableName.contains(" AS ")) {
final String unaliasedName = leftTableName.split(" AS
")[1].strip();
return "JOIN " + leftTableName + " ON " + unaliasedName + "." +
leftKey + "=" + rightTableName + "."
+ rightKey;
} else if (rightTableName.contains(" AS ")) {
final String unaliasedName = rightTableName.split(" AS
")[1].strip();
return "JOIN " + rightTableName + " ON " + leftTableName + "." +
leftKey + "=" + unaliasedName + "."
+ rightKey;
}
return "JOIN " + leftTableName + " ON " + leftTableName + "." +
leftKey + "=" + rightTableName + "." + rightKey;
}
```
This is not ideal either so if you have some sort of structural
changes/ideas for the `createSqlClause()` `.withSqlImplementation()` and
`JdbcExecutor` architecture I'm open for discussion.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]