Hi,
I am trying to learn the lattice feature from Calcite and follow the
https://calcite.apache.org/docs/lattice.html and found one question.
After I load the model:

sqlline> !connect
jdbc:calcite:model=core/src/test/resources/hsqldb-foodmart-lattice-model.json
"sa" ""

Then issue the query

explain plan for
select "the_year","the_month", count(*) as c
from "sales_fact_1997"
join "time_by_day" using ("time_id")
group by "the_year","the_month";

The result is

+------------------------------------------------------------------+
|                               PLAN                               |
+------------------------------------------------------------------+
| JdbcToEnumerableConverter
  JdbcProject(the_year=[$1], the_month=[$0], C=[$2])
    JdbcAggregate(group=[{2, 3}], C=[COUNT()])
      JdbcJoin(condition=[=($0, $1)], joinType=[inner])
        JdbcProject(tim |
+------------------------------------------------------------------+

Instead of

+--------------------------------------------------------------------------------+
| PLAN
     |
+--------------------------------------------------------------------------------+
| EnumerableCalc(expr#0..2=[{inputs}], the_year=[$t1], the_month=[$t0],
C=[$t2]) |
|   EnumerableAggregate(group=[{3, 4}], C=[$SUM0($7)])
     |
|     EnumerableTableScan(table=[[adhoc, m{16, 17, 27, 31, 32, 36, 37}]])
      |
+--------------------------------------------------------------------------------+

Seems like it's not querying the materialized view table.

But I can see that table is existed

sqlline> !tables
m{16, 17, 27, 31, 32, 36, 37}
...

Is there any step or setting I miss?

Thanks for your help.

Brad

Reply via email to