-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-27246][TableSQL/Runtime][master] - Include WHILE blocks in split generated java methods #21393
Conversation
71ce516
to
467d4af
Compare
bd3171a
to
a4f9687
Compare
@flinkbot run azure |
1 similar comment
@flinkbot run azure |
47151f4
to
b14e784
Compare
@flinkbot run azure |
b14e784
to
524a33e
Compare
@flinkbot run azure |
1 similar comment
@flinkbot run azure |
524a33e
to
8237e8a
Compare
@flinkbot run azure |
8237e8a
to
4e8b313
Compare
@flinkbot run azure |
4e8b313
to
859b107
Compare
@flinkbot run azure |
859b107
to
085a1c7
Compare
@flinkbot run azure |
1 similar comment
@flinkbot run azure |
cbbf3d4
to
09b95bc
Compare
@flinkbot run azure |
1 similar comment
@flinkbot run azure |
edf35c1
to
bc1e1db
Compare
@flinkbot run azure |
487ae3e
to
6423ea0
Compare
I've replayed to/implemented changes from your last comments. Regarding If we focus only on IF/ELSE statements without Having:
The original `IfStatementRewritter will not extract:
and
To their's separate methods. They will be extracted together with entire
The test with similar code is implemented in: If you would have 3rd level IF/ELSE after And now you may say, that this is not a big deal. Maybe with an example I'm showing here the gain is hard to spot. However I can tell that for a production job (SQL Query), that was causing FLINK-27246, I have an extracted method that has 537 statements similar to those from example below, that I'm not sure if the original implementation could extract. Plus we have many additional methods containing 2 statements. So even if this would be the only extra thing (except supporting |
6423ea0
to
d2ae921
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kristoffSC for your effort in this long running pull request. I don't have much to say now. You did a great job.
One last comment: Add a test to CodeSplitITCase
to address why this issue is brought up. Maciej Bryński's comment in the original JIRA ticket might be useful.
Hi @tsreaper I was using Maciej Bryński's SQL example from FLINK-27246 ticket to verify if my change here solves the original problem. I will add it to CodeSplitITCase in following days. |
dd6e916
to
c662b00
Compare
…it generated java methods. This PR fix issue reported in https://issues.apache.org/jira/browse/FLINK-27246 that was caused by JavaCodeSplitter not rewriting WHILE statements which was leading to Java compiler being not able to compile code due to big methods. The Proposed change, enhance JavaCodeSplitter by replacing IfStatementRewriter.java with BlockStatementRewriter.java. The new BlockStatementRewriter.java can rewrite both IF/ELSE statements and WHILE blocks including combination of both and nested statements. The BlockStatementRewriter works in two steps. First step extracts blocks from IF/ELSE branches and WHILE bodies to separate methods. This step is executed by new class BlockStatementSplitter. The second step, groups statements (single lien statements, IF/ELSE and WHILE statements) into groups and extract them to new methods. This step is executed by new class BlockStatementGrouper. Signed-off-by: Krzysztof Chmielewski <krzysiek.chmielewski@gmail.com>
c662b00
to
ac87f84
Compare
Hi @tsreaper CI/CD is green. Anything else you would like me to do? If not could you merge this PR? P.S. |
You're welcome to create back ports. As 1.16.0 has just released for one month or two I guess 1.16.1 will come in the near future. However 1.15 is an older version and I can't determine when will we release the next version (or if the next version will ever come). |
…ed java methods. This closes apache#21393. (cherry picked from commit af9a112)
it looks like it generates methods with same signature for some cases e.g. |
I will take a look at this one. This was not causing CI build to fail? |
somehow build doesn't fail Line 106 in 2ae5df2
|
btw, i created an issue for that |
I already have fix, will provide PR shortly. |
…0927. Rewritten code after code splitting could result in more than one method with the same signature and return type. The issue happens whenever split method had more than one IF/ELSE/WHILE statement in series (not tested). Issue was caused by bug in apache#21393. Signed-off-by: Krzysztof Chmielewski <krzysiek.chmielewski@gmail.com>
…0927 - rewritten conde failed at compilation with "non-abstract methods have the same parameter types, declaring type and return type" Rewritten code after code splitting could result in more than one method with the same signature and return type. The issue happens whenever split method had more than one IF/ELSE/WHILE statement in series (not tested). Issue was caused by bug in apache#21393. Signed-off-by: Krzysztof Chmielewski <krzysiek.chmielewski@gmail.com>
…0927 - rewritten conde failed at compilation with "non-abstract methods have the same parameter types, declaring type and return type" Rewritten code after code splitting could result in more than one method with the same signature and return type. The issue happens whenever split method had more than one IF/ELSE/WHILE statement in series (not tested). Issue was caused by bug in apache#21393. Signed-off-by: Krzysztof Chmielewski <krzysiek.chmielewski@gmail.com>
…it generated java methods. This PR fix issue reported in https://issues.apache.org/jira/browse/FLINK-27246 that was caused by JavaCodeSplitter not rewriting WHILE statements which was leading to Java compiler being not able to compile code due to big methods. The Proposed change, enhance JavaCodeSplitter by replacing IfStatementRewriter.java with BlockStatementRewriter.java. The new BlockStatementRewriter.java can rewrite both IF/ELSE statements and WHILE blocks including combination of both and nested statements. The BlockStatementRewriter works in two steps. First step extracts blocks from IF/ELSE branches and WHILE bodies to separate methods. This step is executed by new class BlockStatementSplitter. The second step, groups statements (single lien statements, IF/ELSE and WHILE statements) into groups and extract them to new methods. This step is executed by new class BlockStatementGrouper. [FLINK-30927][TableSQL/Runtime][master][bugfix] - Bug fix for FLINK-30927 - rewritten code failed at compilation with "non-abstract methods have the same parameter types, declaring type and return type" Rewritten code after code splitting could result in more than one method with the same signature and return type. The issue happens whenever split method had more than one IF/ELSE/WHILE statement in series (not tested). Issue was caused by bug in apache#21393. Signed-off-by: Krzysztof Chmielewski <krzysiek.chmielewski@gmail.com>
…ed java methods. This closes apache#21393.
…ed java methods. This closes apache#21393.
What is the purpose of the change
This PR fix issue reported in https://issues.apache.org/jira/browse/FLINK-27246 that was caused by
JavaCodeSplitter
not rewriting "while" statements that was leading to Java compiler not able to compile code due to to big methods.Proposed change, enhance
JavaCodeSplitter
by replacingIfStatementRewriter.java
withBlockStatementRewriter.java
.The new
BlockStatementRewriter.java
can rewrite both IF/ESLE statements and WHILE blocks including nested statements.The
BlockStatementRewriter
works in two steps. First step extracts blocks from IF/ELSE branches and WHILE bodies to separate methods. This step is executed by new classBlockStatementSplitter
.The second step, groups statements (single lien statements, IF/ELSE and WHILE statements) into groups and extract them to new methods. This step is executed by new class
BlockStatementGrouper
.An example of rewritten code:
BEFORE:
AFTER executing BlockStatementRewriter:
Brief change log
Verifying this change
This change is already covered by existing tests, such as
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (no)Documentation