Hi all,

I’m hoping this question is super easy, but I’m running into a bit of a 
roadblock while researching Calcite, and thought maybe someone on here might be 
interested.

So imagine that you have a fairly simple nested data structure, like

TableName struct {
        a int,
        b struct {
                c float
        }
}

And you are wanting to issue the query `select a, b.c from TableName where c = 
3.14`. Getting the basic table scan to plan properly is a pretty 
straightforward task. 

Now suppose that you want to define a materialization of the query `select 
a,b.c from TableName`. When I attempt this, the materialization is never used—I 
tracked it down and it’s because the SubstitutionVisitor does not appear to 
consider it a “true” substitution (mundane details below). 

So my question is this: Is this type of materialization possible? If so, how 
would I go about it? (In broad terms, at least).

Thanks for your help!

Scott Fines

Code details:

The SubstitutionVisitor runs into a situation where it finds that the MVT is an 
equivalent expression, but does not believe it to be a “true” substitution. 
Specifically, `targetDescendent != this.target`, so the substitution is 
discarded. I’m not sure of the reasoning for why the visitor requires object 
equality here, perhaps there is some more context I am missing?

Reply via email to