You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2015/10/24 01:29:27 UTC

[jira] [Resolved] (CALCITE-890) Register all combinations of materialization substitutions

     [ https://issues.apache.org/jira/browse/CALCITE-890?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde resolved CALCITE-890.
---------------------------------
    Resolution: Fixed

Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/9d0fef31. Thanks for the patch, [~maryannxue]!

> Register all combinations of materialization substitutions
> ----------------------------------------------------------
>
>                 Key: CALCITE-890
>                 URL: https://issues.apache.org/jira/browse/CALCITE-890
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>             Fix For: 1.5.0
>
>         Attachments: CALCITE-890.patch
>
>
> When a query has multiple table references, there could be:
> 1) Multiple combinations of substituted Rels if one materialization is applicable for more than one sub-tree.
> 2) Multiple combinations of substituted Rels if different materializations are applicable for different sub-trees respectively.
> {code}
>   @Test public void testSingleMaterializationMultiUsage() {
>     String q = "select *\n"
>         + "from (select * from \"emps\" where \"empid\" < 300)\n"
>         + "join (select * from \"emps\" where \"empid\" < 200) using (\"empid\")";
>     try {
>       Prepare.THREAD_TRIM.set(true);
>       MaterializationService.setThreadLocal();
>       CalciteAssert.that()
>           .withMaterializations(JdbcTest.HR_MODEL, 
>               "m0", "select * from \"emps\" where \"empid\" < 500")              
>           .query(q)
>           .enableMaterializations(true)
>           .explainMatches("", new Function<ResultSet, Void>() {
>             public Void apply(ResultSet s) {
>               try {
>                 final String actual = Util.toLinux(CalciteAssert.toString(s));
>                 final String scan = "EnumerableTableScan(table=[[hr, m0]])";
>                 assertTrue(actual + " should have had two occurrences of " + scan, 
>                     StringUtils.countMatches(actual, scan) == 2);
>                 return null;
>               } catch (SQLException e) {
>                 throw new RuntimeException(e);
>               }
>             }
>           })
>           .sameResultWithMaterializationsDisabled();
>     } finally {
>       Prepare.THREAD_TRIM.set(false);
>     }
>   }
>   @Test public void testMultiMaterializationMultiUsage() {
>     String q = "select *\n"
>         + "from (select * from \"emps\" where \"empid\" < 300)\n"
>         + "join (select * from \"emps\" where \"deptno\" < 10) using (\"empid\")";
>     try {
>       Prepare.THREAD_TRIM.set(true);
>       MaterializationService.setThreadLocal();
>       CalciteAssert.that()
>           .withMaterializations(JdbcTest.HR_MODEL, 
>               "m0", "select * from \"emps\" where \"empid\" < 500",
>               "m1", "select * from \"emps\" where \"deptno\" < 20")              
>           .query(q)
>           .enableMaterializations(true)
>           .explainContains("EnumerableTableScan(table=[[hr, m0]])")
>           .explainContains("EnumerableTableScan(table=[[hr, m1]])")
>           .sameResultWithMaterializationsDisabled();
>     } finally {
>       Prepare.THREAD_TRIM.set(false);
>     }
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)