In current Calcite implementation for query : SELECT TRIM('ABC') for SPARK Dialect it gets translated into SELECT TRIM(BOTH ' ' FROM 'ABC') .
But the proper query for SPARK is :: SELECT TRIM('ABC')
Unparse logic for the trim has been handled in Spark dialect to convert the source Trim query into valid SPARK query.
Also,In HIVE/SPARK dialect TRIM with two operand is not supported
Eg: SELECT TRIM(BOTH 'a' from 'ABC') So its equivalent is REGEXP_REPLACE which is handle in unparseTrim function.