calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Hyde <>
Subject Re: Translate "$0" to real name
Date Thu, 25 Feb 2016 22:31:27 GMT

Thanks for chiming in.

And, I’m very excited to see another project using Calcite. Nice work.

May I include SQL-Gremlin in the list of adapters on

Would it make sense to convert SQL-Gremlin into a true adapter (i.e. provide an implementation
of SchemaFactory so that you could include a Gremlin schema in a Calcite model file alongside
other schemas)?


> On Feb 25, 2016, at 6:02 AM, Ted Wilmes <> wrote:
> Not sure if this would be of any help, but I worked through a similar sort of thing in
this class:
> I'm using Calcite as part of a project that converts SQL to the Gremlin graph query language.
 Because of how the Gremlin queries are constructed, I needed to be able to trace the provenance
of the columns at each level back to their original column name.  This particular code is
executed during a depth first traversal of the RelNodes.
> --Ted
> ________________________________________
> From: Julian Hyde <>
> Sent: Wednesday, February 24, 2016 6:44 PM
> To:
> Subject: Re: Translate "$0" to real name
> 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 <> 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

View raw message