Writing a rule would certainly work. You would want to match a Filter RelNode and then perhaps use an implementation of RexShuttle on the condition and implement visitCall to check for appropriate casts to be transformed into the subquery you want using RexSubQuery.scalar to generate the new query.
-- Michael Mior [email protected] Le mar. 26 févr. 2019 à 05:55, Muhammad Gelbana <[email protected]> a écrit : > > I'm willing to implement running PostgreSQL queries involving OID casts > > *For example:* > SELECT * FROM pg_attribute > WHERE attrelid = 'mytable'::regclass; > > *Should be executed as:* > SELECT * FROM pg_attribute > WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mytable'); > > Note that *reglass* maps to the *pg_class* table. > > What is the "calcite way" to implement this ? Should I write a rule ? > Or should I rewrite the query before implementing it (I'm not sure where is > that) ? > > Thanks, > Gelbana
