In current Calcite implementation for query : SELECT TRIM('ABC') for big-query Dialect it translated into SELECT TRIM(BOTH ' ' FROM 'ABC') .
But the appropriate query for BigQuery is :: SELECT TRIM('ABC')
Similarly below query
SELECT TRIM(BOTH 'a' from 'ABC')
SELECT TRIM(LEADING ' ' from 'ABC')
SELECT TRIM(TRAILING ' ' from 'ABC') are translated into invalid BigQuery query.
Unparse logic for the trim has been handle in BigQuery dialect to convert the source Trim query into valid bigQuery query.