Vladimir may have fixed this issue in
https://github.com/julianhyde/optiq/commit/32738eb23fadee5091351813b261c4fe48dd3407.
I notice that he added a very similar test case in JdbcTest:
```java
/** Tests derived return type of user-defined function. */
@Test public void testUdfDerivedReturnType() {
final OptiqAssert.AssertThat with = withUdf();
with.query(
"select max(\"adhoc\".my_double(\"deptno\")) as p from
\"adhoc\".EMPLOYEES")
.returns(
"P=40\n");
with.query(
"select max(\"adhoc\".my_str(\"name\")) as p from \"adhoc\".EMPLOYEES\n"
+ "where \"adhoc\".my_str(\"name\") is null")
.returns(
"P=null\n");
}
```
Julian