Currently the Baz classes that are used to execute queries in the EnumerableConvention are stateful since the code generated by EnumerableRelImplementor#implementRoot method creates an instance variable (i.e., DataContext root). Every call to the bind method changes the value of the root variable making the object mutable.
I propose to remove the instance variable and in the body of the method use the DataContext passed as a parameter.
It appears that the addition of the instance variable was a workaround for a bug in Janino (JANINO-169). It seems that the bug is no longer present at the current version of Janino used in Calcite (3.0.9) since the test JdbcTest#testJanino169 (and the complete suite) pass successfully with the proposed modification.
Unfortunately, I couldn't verify the fix in the release notes of Janino neither in the commit history. The best, I could find is the following commits in the Janino repository: