You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jonathan A Sternberg (Jira)" <ji...@apache.org> on 2023/03/06 21:05:00 UTC
[jira] [Created] (CALCITE-5561) HepProgramBuilder.addSubprogram does not add a subprogram
Jonathan A Sternberg created CALCITE-5561:
---------------------------------------------
Summary: HepProgramBuilder.addSubprogram does not add a subprogram
Key: CALCITE-5561
URL: https://issues.apache.org/jira/browse/CALCITE-5561
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.33.0
Reporter: Jonathan A Sternberg
Attachments: hepsubquery.patch
It appears that the {{addSubprogram}} method in {{HepProgramBuilder}} might not be working as advertised. The [javadoc|https://calcite.apache.org/javadocAggregate/org/apache/calcite/plan/hep/HepProgramBuilder.html#addSubprogram(org.apache.calcite.plan.hep.HepProgram)] indicates that the subprogram will be run repeatedly until the fix point is reached or no changes have been made (whichever comes first).
On the other hand, when using this method and running the associated {{{}HepProgram{}}}, the subprogram doesn't appear to run repeatedly.
When I run the unit test for testing this and I try to set a breakpoint in {{{}executeSubquery{}}}, that line of code is never hit. I believe the error might be here: [https://github.com/apache/calcite/blob/ee9b80b0b68d442991dfaa142722e3488ec73e79/core/src/main/java/org/apache/calcite/plan/hep/HepInstruction.java#L273]
I think that this line is calling prepare for the subprogram itself and returning the state for the underlying program rather than returning the state associated with the subprogram. This causes it to never run [this code|https://github.com/apache/calcite/blob/ee9b80b0b68d442991dfaa142722e3488ec73e79/core/src/main/java/org/apache/calcite/plan/hep/HepInstruction.java#L290] (which internally runs the program repeatedly).
I've attached a diff that seems to fix it for me, but I'm not sure how I would write an appropriate unit test for it. I can submit it as a PR and get help with writing the test.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)