Hey Christian,

On Thu, Feb 13, 2020 at 6:30 PM Christian Beikov <christian.bei...@gmail.com>
wrote:

> Hello,
>
> I'm trying to generate SQL for a trigger that requires a little rewrite
> of a RelNode structure and I wanted to know if anyone could help me
> figure out how to do a few things
>
>   * I need to swap left and right of a LogicalJoin. Doing that messes up
>     predicates and projections though. Is there a utility I could use or
>     how would I do that?
>

You can use JoinCommuteRule, or check it's code for your needs.


>   * I need to introduce an "alias" like "NEW" into a RelNode for which I
>     want to create a RexNode "NEW.key1" for. I want to add a WHERE
>     condition based on the NEW alias. Not sure how I would do that
>     though. On SqlNode level only maybe?
>

I don't understand what you're after here. The WHERE condition will be a
filter node. Can you just add it with attaching something to the rel node?


>   * Can I somehow determine what columns of a table are unique or part
>     of the primary key? I want to create a predicate like (NEW.key1,
>     NEW.key2) = (existing.key1, existing.key2)
>

You can use RelMetadataQuery.

Best,

Jess


>
> Thanks in advance!
>
> Regards,
>
> Christian
>
>

Reply via email to