[ 
https://issues.apache.org/jira/browse/CALCITE-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388291#comment-14388291
 ] 

Ng Jiunn Jye commented on CALCITE-631:
--------------------------------------

Found the problem. 

For your information. I have rerun with EnumerableJoinRule disabled (removing 
from CalcitePrepareImpl). The JVM still crash with OOM error. 

After breaking down the test suite and run them one by one, managed to identify 
the failure at JdbcTest.testSelfJoinCount introduced by CALCITE-70. The 
JdbcJoin has pushed the join operation to HSQL and the query blew up HSQL. This 
can be simulated by executing query on HSQL thus showing it is a HSQL issues. 

I will modify the test to run against a smaller table. 

Test Query : 
   select count(*) as c 
   from "foodmart"."sales_fact_1997" as p1 
   join "foodmart"."sales_fact_1997" as p2 using ("store_id")

Generated Query after JdbcJoin: 
   SELECT COUNT(*) AS "C" 
   FROM (SELECT 0 AS "DUMMY" 
      FROM (SELECT "store_id" 
           FROM "foodmart"."sales_fact_1997") AS "t" "
   INNER JOIN (SELECT "store_id" 
   FROM "foodmart"."sales_fact_1997") AS "t0" 
   ON "t"."store_id" = "t0"."store_id") AS "t1""

OutOfMemoryStackTrace:
   JVMDUMP013I Processed dump event "systhrow", detail 
"java/lang/OutOfMemoryError".
   java.sql.SQLException: java.lang.OutOfMemoryError: Java heap space
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.executeQuery(Unknown Source)
        at 
org.apache.calcite.jdbc.JayTestFoodMartHSQL.testStatement(JayTestFoodMartHSQL.java:43)
        at 
org.apache.calcite.jdbc.JayTestFoodMartHSQL.main(JayTestFoodMartHSQL.java:29)
Caused by: org.hsqldb.HsqlException: java.lang.OutOfMemoryError: Java heap space
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.result.Result.newErrorResult(Unknown Source)
        at org.hsqldb.StatementDMQL.execute(Unknown Source)
        at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
        at org.hsqldb.Session.executeDirectStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        ... 4 more
Caused by: java.lang.OutOfMemoryError: Java heap space
        at org.hsqldb.QuerySpecification.buildResult(Unknown Source)
        at org.hsqldb.QuerySpecification.getSingleResult(Unknown Source)
        at org.hsqldb.QuerySpecification.getResult(Unknown Source)
        at org.hsqldb.TableDerived.materialise(Unknown Source)
        at org.hsqldb.StatementDMQL.materializeSubQueries(Unknown Source)

Test Code: 
package org.apache.calcite.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class JayTestFoodMartHSQL {

  private static Connection connection;
  public static void main(String[] args) {
    try {

      connection = DriverManager.getConnection(
          "jdbc:hsqldb:res:foodmart", "FOODMART", "FOODMART");

      ResultSet rs  = connection.createStatement().executeQuery("SELECT 
COUNT(*) AS \"C\" "
                      + " FROM (SELECT 0 AS \"DUMMY\" "
                      + "FROM (SELECT \"store_id\" "
                      + "FROM \"foodmart\".\"sales_fact_1997\") AS \"t\" "
                      + "INNER JOIN (SELECT \"store_id\" "
                      + "FROM \"foodmart\".\"sales_fact_1997\") AS \"t0\" ON 
\"t\".\"store_id\" = \"t0\".\"store_id\") AS \"t1\"");
      
      rs.next();
      System.out.println("Count is " + rs.getInt(1));
      rs.close();
      connection.close();      
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}


> Push theta joins down to JDBC adapter
> -------------------------------------
>
>                 Key: CALCITE-631
>                 URL: https://issues.apache.org/jira/browse/CALCITE-631
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Ng Jiunn Jye
>            Assignee: Julian Hyde
>             Fix For: next
>
>         Attachments: [CALCITE-631]JdbcJoinToSupportNonEquiJoin.2.patch, 
> [CALCITE-631]JdbcJoinToSupportNonEquiJoin.patch
>
>
> Currently, the JdbcJoin only support EquiJoin. ie select * from tab1 inner 
> join tab2 on tab1.col1=tab2.col2
> NonEqui join are not supported in JdbcJoin, thus resulting execution plan 
> which uses EnumerationJoin and EnumerableCalc for joining and not pushing the 
> join down to remote database. 



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

Reply via email to