I was able to handle it using CAST(“myString” as VARCHAR(8000)).
For example,
SELECT REPLACE(CAST(‘A SPIDER WITH AN ANT’ AS VARCHAR(8000)), ‘AN’, ‘THIN’) FROM data.“mine”.doc LIMIT 1
The issue was that Dremio keeps the original input’s length, even if the replace function generates a longer string. When the output is longer than the original string, it doesn’t have enough space to be displayed or returned completely.
I believe this only happens when the replace function is applied to a literal string in the query. If applied to a column in a table, it will treat the column as varchar, and behave as expected.