As I commented in https://issues.apache.org/jira/browse/CALCITE-5159 <https://issues.apache.org/jira/browse/CALCITE-5159>, this feature is more like an array literal. Consider that
DATE ‘2022-05-19’ is a date literal, and if I write INSERT INTO t (dateColumn) VALUES (‘2022-05-19’) or SELECT * FROM t WHERE dateColumn = ‘2022-05-19’ the character literals become date literals. This array literal seems to work similarly. The parsing can happen at prepare time, and if the literal is invalid prepare should fail. Julian > On May 19, 2022, at 1:48 AM, Dmitry Sysolyatin <dm.sysolya...@gmail.com> > wrote: > > Thanks! > But I think I shouldn't create my own implementation of TypeCoercion. I can > just extend the existing TypeCoercionImpl if I will add > isStringToArrayCastEnabled() (by analogy with isTypeCoercionEnabled) to > SqlCallBinding in order to only postgres dialect has this feature. > > On Mon, May 16, 2022 at 12:35 PM Stamatis Zampetakis <zabe...@gmail.com> > wrote: > >> Hi Dmitry, >> >> There is the TypeCoercion [1] interface that allows you to customize how >> implicit casts work. >> I guess you need to create your own implementation, customize the behavior >> of the binaryComparisonCoercion method (possibly others as well), and pass >> it to the validator. >> >> Best, >> Stamatis >> >> [1] >> >> https://github.com/apache/calcite/blob/1bce280a2957326dc5c249cfd079edfd2c54adf4/core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercion.java >> >> On Thu, May 12, 2022 at 4:42 PM Dmitry Sysolyatin <dm.sysolya...@gmail.com >>> >> wrote: >> >>> Hi! >>> >>> I would like to implement implicit cast from string to array as PG does. >>> For example: "SELECT ARRAY[1,2,3] = '{1,2,3};'" should return true >> instead >>> of exception for Postgres dialect >>> >>> Is there an easy way to implement implicit cast? >>> >>