Assignment conversion not possible from type "java.lang.Object" to type "xxxxxx"


I tried to add a custom function in “dremio”.

This function is like this: first, load the resource file prepared in advance from the “resources” folder, which is a CSV file, then load it into memory, use a “HashMap” to save it, and then use it in the function. I use generics here.

Map<String,cn.custom.udf.geo.Geo> geoMap = new HashMap<>();

It is used as follows:

geo = geoMap.get(stringInput);

However, when the query is run, an error is found:

CompileException: Line 63, Column 5: Assignment conversion not possible from type "java.lang.Object" to type "cn.custom.udf.geo.Geo".

What I am confused about now is whether I can’t use generics here?

But using HashMap has higher query efficiency.

Thanks for any suggestions.


I finally solved this problem by modifying the Map to a specific implementation class, such as HashMap.
This should be the “janino” problem, but dremio seems to lack relevant documentation. I think this problem should be recorded here to remind the following people.

@bigfacewo That’s amazing work, thanks for the update

I have summarized the problems worth explaining:

  1. “Map” needs to be rewritten into a specific implementation class, such as HashMap.
  2. All implicit conversions need to be written as display conversions, even if the IDE does not think it is necessary, because “janino” does not support implicit conversions.
  3. The full path should be written for the reference of non “JDK” classes.
  4. The parameter decorated with @param in the user-defined function is used as input, and its value should be taken from the starting position of the input, not from 0.

If you pay attention to the above problems, the journey of developing custom functions should be very smooth.