If you do want to have a planner rule to do such transformation, consider putting the rule in a HepPlanner in stead of VolcanoPlanner, if you have not tried that approach.
On Mon, Mar 27, 2017 at 8:50 AM, Julian Hyde <[email protected]> wrote: > It’s problematic doing such a transformation in a rule. Why? Rules are > supposed to preserve semantics, i.e. convert a RelNode to one that produces > the same result. If a rule converts A to B then the engine is at liberty to > choose A or B (or something derived from A, or something derived from B), > whichever is cheaper. And that’s valid because they all give the same result, > right?! > > Try this: write your own RelShuttle (RelShuttleImpl and RelHomogeneousShuttle > are useful partial implementations) and apply it soon after Sql-to-rel > translation. > > Julian > > > > > >> On Mar 24, 2017, at 7:16 PM, Jingwu Li <[email protected]> wrote: >> >> Hi all, >> >> Is there a way to do value transformation for a sql query? For >> example, select * from user where user_id = 1234 need to transform to select >> * from user where user_id = 5678. >> >> I have tried to create a planner rule similar to JdbcFilterRule which >> match the LogicalFilter and created a value transformer visitor to do the >> value transformation. But after the optimization phase, ether my cutomized >> transformation relnode does not get selected due to the cost is not cheapest >> or the transformation has applied multiple times thus the value got >> transformed to unexpected value ( 1234 -> 5678 -> 9012 ...). Is this a right >> place to do such value transformation? >> >> I also looked at the query parsing phase and try to find a place to get >> the parsed sqlnode tree. It seems hard to add a visitor to do the >> transformation when traversal the tree. >> >> Could you give some thoughts? >> >> >> Regards, >> >> Jingwu Li >> >> >> >
