[jira] [Created] (CALCITE-4198) Query contains AVG function, materialized view contains SUM and COUNT functions, and materialized recognition fails

2020-08-27 Thread xzh_dz (Jira)
xzh_dz created CALCITE-4198:
---

 Summary: Query contains AVG function, materialized view contains 
SUM and COUNT functions, and materialized recognition fails
 Key: CALCITE-4198
 URL: https://issues.apache.org/jira/browse/CALCITE-4198
 Project: Calcite
  Issue Type: Wish
Reporter: xzh_dz


There is a semantic equivalent case, which should be able to materialize and 
identify successfully, materialized view can express the calculation logic of 
query,but failed. This case can be reproduced as below.
{code:java}
// MaterializedViewSubstitutionVisitorTest
@Test void testAvgMvMatch() {
  sql(
  "select \"empid\", sum(\"salary\"), count(\"salary\") from \"emps\" where 
\"empid\" > 10 group by \"empid\"",
  "select \"empid\", avg(\"salary\") from \"emps\" where \"empid\" > 10 
group by \"empid\"")
  .ok();
}
{code}
The error message:
{code:java}
java.lang.AssertionError: Materialized view failed to be matched by optimized 
results:java.lang.AssertionError: Materialized view failed to be matched by 
optimized results: at 
org.apache.calcite.test.AbstractMaterializedViewTest.checkMaterialize(AbstractMaterializedViewTest.java:112)
 at 
org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:64)
 at 
org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:227)
 at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at 
org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:275)
 at 
org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:446) 
at com.sun.proxy.$Proxy12.ok(Unknown Source) at 
org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testAvgMvMatch(MaterializedViewSubstitutionVisitorTest.java:101)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (CALCITE-4197) Provide utility to visualize RelNode plans

2020-08-27 Thread Liya Fan (Jira)
Liya Fan created CALCITE-4197:
-

 Summary: Provide utility to visualize RelNode plans
 Key: CALCITE-4197
 URL: https://issues.apache.org/jira/browse/CALCITE-4197
 Project: Calcite
  Issue Type: New Feature
  Components: core
Reporter: Liya Fan
Assignee: Liya Fan


>From time to time, we want to visualize the plan generated the optimizer as a 
>DAG (Directed Acyclic Graph). This gives us an overview of the plan, and helps 
>us to find problems with the plan quickly.

A common way to visualize a DAG is to dump it in the {{dot}} format, and then 
display the DAG through GraphViz. Currently, we already have a utility to dump 
the Volcano planner in dot format. In this issue, we want to dump a RelNode 
plan (a RelNode DAG) in the dot format, which will help users to see their 
plans more clearly. 

The utility should have some options that allow users to specify the 
visuzalization details, for example:
1. the max length of a node description.
2. whether RelSubset/HepRelVertex should be displayed.
3. Nodes that should be highlighted. 

Could you please give some feedback?





--
This message was sent by Atlassian Jira
(v8.3.4#803005)