Skip to content

Conversation

@treyfel
Copy link
Contributor

@treyfel treyfel commented Jan 6, 2026

  • Corrected the SQL JOIN clause in JdbcJoinOperator#createSqlClause to use the right table name when forming the JOIN statement, ensuring the SQL query generated is not a self-join.

  • Updated the expected SQL query in JdbcJoinOperatorTest#testWithHsqldb to match the corrected JOIN clause logic.

@mspruc mspruc self-assigned this Jan 7, 2026
@mspruc
Copy link
Contributor

mspruc commented Jan 7, 2026

ty for your contribution,

I'm not entirely sure I understand the issue you are trying to fix here, JdbcJoinOperator.createSqlClause() now uses the right table name twice, but what about the left table name then?

Can I ask what issue prompted the change? If you have a stack trace or something I can also take a look at it.

Copy link
Contributor

@kamir kamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check if I got it right and if my suggestions is in line with your goal.
And please clarify the goal if it is something else.
Cheers, Mirko

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem was in the test class:

SELECT * FROM testA JOIN testA ON testB.a=testA.a;

In JdbcJoinOperator.java‎
the code looks good.

@treyfel
Copy link
Contributor Author

treyfel commented Jan 7, 2026

ty for your contribution,

I'm not entirely sure I understand the issue you are trying to fix here, JdbcJoinOperator.createSqlClause() now uses the right table name twice, but what about the left table name then?

The left table name comes from the tableSource JdbcTableSource.createSqlClause().

Can I ask what issue prompted the change? If you have a stack trace or something I can also take a look at it.

There was no initial issue as the tests we’re green but when working on something regarding join operations on the jdbc platform, I noticed the test checks for a self join syntax, which I assume was not intended.

@zkaoudi
Copy link
Contributor

zkaoudi commented Jan 8, 2026

+1 for this PR.
The left table is created as a "FROM $leftTableName" statement in the source operator. In the proposed change the "JOIN" should be done on the right table as a string of "JOIN $rightTableName". Then the equality "ON" comes where it doesn't matter the order of the predicates.

@treyfel maybe you can split up the return string into two strings (join part and predicates part) so that it's not confusing with a single return statement

@mspruc
Copy link
Contributor

mspruc commented Jan 9, 2026

let's merge this, I still have some outstanding issues with how we handle createSqlClause() and .withSqlImplementation() as ive previously mentioned in #643 but I have something for that in the pipeline, for now this should be fine @zkaoudi @kamir

@zkaoudi
Copy link
Contributor

zkaoudi commented Jan 12, 2026

Hi @kamir, can you merge the PR? The suggested changes are correct

@kamir kamir merged commit 8276bf2 into apache:main Jan 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants