select cast("timestamp" as timestamp) as t from "foodmart" order by t limit 1
select cast(cast("timestamp" as timestamp) as varchar) as t from "foodmart" order by t limit 1
The second query should returns with the same format as the first one.
See test case:
DruidAdapterIT regression after 1.17 release
Remove redundant CAST when operand has exactly the same type as it is casted to
Simplify casts which are only widening nullability
GitHub Pull Request #1120