calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Hyde <jh...@apache.org>
Subject Re: Translate "$0" to real name
Date Thu, 25 Feb 2016 00:44:02 GMT
Scalar expressions (RexNode) are, by design, separate from relational expressions (RelNode).
Therefore a reference to an input field (RexInputRef) contains the ordinal and type of the
field that it references but not its name or any other information.

It’s useful that RexNodes are self-contained; they are easier to canonize, and there are
fewer concerns about them being the source of memory leaks.

If you want to print extra information about a RexNode you need to supply the list of RelNodes
that are the context. When used in a Filter or Project, that list is just [input]. When used
in a Join, that list is [left, right]. 

It would be nice if, say, the explain of Filter, Project and Join used the input field names
rather than $n. If you wrote this we could hook it up.

Lastly, note that the names of the fields of RelNodes may not be the “real names” you
are hoping for. We try to preserve the names from SQL, but there are times when they get lost,
especially after applying transformation rules. All we can really guarantee is that the names
are unique within each input.

Julian


> On Feb 23, 2016, at 5:54 PM, Matt Bateman <matt@lycono.com> wrote:
> 
> Hi All,
> 
> I'm sure this is something simple I'm missing. When evaluating a where
> clause the RexInputRef uses the "$index" notation. How do I get from there
> to the actual name of the column? The javadoc for RexInputRef talks about
> this but doesn't indicate how to do the actual translation.
> 
> Thanks,
> 
> Matt


Mime
View raw message