Hi friends,
I'm reading the CsvFilterableTable.java code in the Calicte example/csv module.
I wrote test code to verify the processing of the SQL `SELECT * FROM orders
WHERE id > 2`.
Its execution plan is as follows:
``bash
EnumerableInterpreter
BindableTableScan(table=[[orders]], filters=[[>(CAST($0):INTEGER NOT NULL, 2)]])
```
Because id > 2 was not filtered while reading by CsvEnumerator#moveNext(), I
later learned that `CsvFilterableTable#addFilter()` does not remove filters
that do not meet the criteria, so the filters are still processed by
TableScanNode#createFilterable(). Since I haven't used Janino before, I
encountered a problem while reading the following code:
``java
final Scalar condition =
compiler.compile(ImmutableList.of(filter2), inputRowType);
final Context context = compiler.createContext();
enumerable = enumerable.where(row -> {
context.values = row.getValues();
Boolean b = (Boolean) condition.execute(context);
return b != null && b;
});
```
I added the janino debug configuration in IDEA as follows:
```bash
-Dorg.codehaus.janino.source_debugging.enable=true
-Dorg.codehaus.janino.source_debugging.dir=/opt/code/java/calcite-all/1.37/example/csv/generated/janino-debug
```
I did see the code files generated by janino, but the generated code only
contained methods. When I manually created class files, pasted the methods into
them, and debugged, I found that the line numbers were misaligned.
```java
public org.apache.calcite.interpreter.Scalar apply(final
org.apache.calcite.DataContext root) {
return new org.apache.calcite.interpreter.Scalar(){
public void execute(org.apache.calcite.interpreter.Context context, Object[]
outputValues) {
final Object[] current = context.values;
final String input_value = current[0] == null ? null : current[0].toString();
outputValues[0] = (input_value == null ? 0 :
org.apache.calcite.runtime.SqlFunctions.toInt(input_value)) > 2;
}
public Object execute(org.apache.calcite.interpreter.Context context) {
final Object[] values = new Object[1];
this.execute(context, values);
return values[0];
} };
}
public Object apply(Object root) {
return this.apply((org.apache.calcite.DataContext) root);
}
```
I don't know how to debug the function code generated above.
Thanks for your other replies.