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

Ulrich Kramer commented on CALCITE-5832:
----------------------------------------

After catching the exception 

{code:java}
    try {
      ruleDriver.drive();
    } catch ( RuntimeException exc){
    //if (LOGGER.isTraceEnabled()) {
      final PrintWriter pw = new PrintWriter(System.err);
      dump(pw);
      pw.flush();
      throw exc;
    }
{code}

the following output is generated:

{code}
Root: rel#92:RelSubset#12.ENUMERABLE.[1]
Original rel:
LogicalSort(sort0=[$1], dir0=[ASC], offset=[0], fetch=[500]): rowcount = 500.0, 
cumulative cost = {825302.4778007811 rows, 5805422.867690865 cpu, 0.0 io}, id = 
60
  LogicalProject(_metadata.status=[$10], doi=[$9], industry.title=[$11], 
crm_account.crm_account_name=[$12], assettitle=[$6], description=[$4], 
assettype=[$7], format=[$3], contentviewscount=[$0], metadatapreviewurl=[$2], 
language=[$5], contenttype=[$8], isexpired=[$1]): rowcount = 559.9514003906249, 
cumulative cost = {824802.4778007811 rows, 5582710.643205077 cpu, 0.0 io}, id = 
59
    LogicalFilter(condition=[AND(=($1, ?0), OR(=($5, ?1), =($5, ?2)), OR(=($8, 
?3), =($8, ?4)), =($9, ?5))]): rowcount = 559.9514003906249, cumulative cost = 
{824242.5264003905 rows, 5575431.274999999 cpu, 0.0 io}, id = 58
      LogicalProject(contentviewscount=[$0], isexpired=[$1], 
metadatapreviewurl=[$2], format=[$3], description=[$4], language=[$5], 
assettitle=[$6], assettype=[$7], contenttype=[$8], doi=[$9], 
_metadata.status=[null:NULL], industry.title=[$14], 
crm_account.crm_account_name=[$16]): rowcount = 398187.6625, cumulative cost = 
{823682.575 rows, 5177243.6125 cpu, 0.0 io}, id = 57
        LogicalJoin(condition=[=($10, $15)], joinType=[left]): rowcount = 
398187.6625, cumulative cost = {425494.9125 rows, 804.0 cpu, 0.0 io}, id = 56
          LogicalJoin(condition=[=($12, $13)], joinType=[left]): rowcount = 
25122.25, cumulative cost = {27107.25 rows, 503.0 cpu, 0.0 io}, id = 53
            LogicalJoin(condition=[=($9, $11)], joinType=[left]): rowcount = 
1585.0, cumulative cost = {1785.0 rows, 202.0 cpu, 0.0 io}, id = 31
              JdbcTableScan(table=[[BASEJDBC, T1]]): rowcount = 100.0, 
cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 1
              JdbcTableScan(table=[[BASEJDBC, T2]]): rowcount = 100.0, 
cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 3
            LogicalProject(industry.semaphoreId=[$0], industry.title=[$1]): 
rowcount = 100.0, cumulative cost = {200.0 rows, 301.0 cpu, 0.0 io}, id = 52
              JdbcTableScan(table=[[BASEJDBC, T3]]): rowcount = 100.0, 
cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 7
          LogicalProject(crm_account.CRM_Account_ID=[$1], 
crm_account.crm_account_name=[$2]): rowcount = 100.0, cumulative cost = {200.0 
rows, 301.0 cpu, 0.0 io}, id = 55
            JdbcTableScan(table=[[BASEJDBC, T4]]): rowcount = 100.0, cumulative 
cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 12

Sets:
Set#0, type: RecordType(INTEGER contentViewsCount, BOOLEAN isExpired, 
VARCHAR(100) metadataPreviewUrl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assetTitle, VARCHAR(100) assetType, 
VARCHAR(100) contentType, VARCHAR(100) doi, VARCHAR(100) crmBpn)
        rel#61:RelSubset#0.JDBC.BASEJDBC.[], best=rel#1
                rel#1:JdbcTableScan.JDBC.BASEJDBC.[](table=[BASEJDBC, T1]), 
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
                
rel#252:JdbcSort.JDBC.BASEJDBC.[9](input=RelSubset#61,sort0=$9,dir0=ASC), 
rowcount=100.0, cumulative cost={190.0 rows, 23311.057737379982 cpu, 0.0 io}
        rel#96:RelSubset#0.ENUMERABLE.[], best=rel#95
                
rel#95:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#61), 
rowcount=100.0, cumulative cost={110.0 rows, 111.0 cpu, 0.0 io}
                
rel#104:AbstractConverter.ENUMERABLE.[9](input=RelSubset#96,convention=ENUMERABLE,sort=[9]),
 rowcount=100.0, cumulative cost={inf}
                
rel#251:EnumerableSort.ENUMERABLE.[9](input=RelSubset#96,sort0=$9,dir0=ASC), 
rowcount=100.0, cumulative cost={210.0 rows, 25899.953041533314 cpu, 0.0 io}
                
rel#361:JdbcToEnumerableConverter.ENUMERABLE.[9](input=RelSubset#253), 
rowcount=100.0, cumulative cost={200.0 rows, 23321.057737379982 cpu, 0.0 io}
        rel#103:RelSubset#0.ENUMERABLE.[9], best=rel#361
                
rel#104:AbstractConverter.ENUMERABLE.[9](input=RelSubset#96,convention=ENUMERABLE,sort=[9]),
 rowcount=100.0, cumulative cost={inf}
                
rel#251:EnumerableSort.ENUMERABLE.[9](input=RelSubset#96,sort0=$9,dir0=ASC), 
rowcount=100.0, cumulative cost={210.0 rows, 25899.953041533314 cpu, 0.0 io}
                
rel#361:JdbcToEnumerableConverter.ENUMERABLE.[9](input=RelSubset#253), 
rowcount=100.0, cumulative cost={200.0 rows, 23321.057737379982 cpu, 0.0 io}
        rel#171:RelSubset#0.NONE.[9], best=null
                
rel#170:LogicalSort.NONE.[9](input=RelSubset#96,sort0=$9,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#253:RelSubset#0.JDBC.BASEJDBC.[9], best=rel#252
                
rel#252:JdbcSort.JDBC.BASEJDBC.[9](input=RelSubset#61,sort0=$9,dir0=ASC), 
rowcount=100.0, cumulative cost={190.0 rows, 23311.057737379982 cpu, 0.0 io}
Set#1, type: RecordType(VARCHAR(100) doi, VARCHAR(100) industry)
        rel#62:RelSubset#1.JDBC.BASEJDBC.[], best=rel#3
                rel#3:JdbcTableScan.JDBC.BASEJDBC.[](table=[BASEJDBC, T2]), 
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
                
rel#255:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#62,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={190.0 rows, 8390.306334778565 cpu, 0.0 io}
        rel#99:RelSubset#1.ENUMERABLE.[], best=rel#98
                
rel#98:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#62), 
rowcount=100.0, cumulative cost={110.0 rows, 111.0 cpu, 0.0 io}
                
rel#106:AbstractConverter.ENUMERABLE.[0](input=RelSubset#99,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#254:EnumerableSort.ENUMERABLE.[0](input=RelSubset#99,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={210.0 rows, 9321.340371976183 cpu, 0.0 io}
                
rel#363:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#256), 
rowcount=100.0, cumulative cost={200.0 rows, 8400.306334778565 cpu, 0.0 io}
        rel#105:RelSubset#1.ENUMERABLE.[0], best=rel#363
                
rel#106:AbstractConverter.ENUMERABLE.[0](input=RelSubset#99,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#254:EnumerableSort.ENUMERABLE.[0](input=RelSubset#99,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={210.0 rows, 9321.340371976183 cpu, 0.0 io}
                
rel#363:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#256), 
rowcount=100.0, cumulative cost={200.0 rows, 8400.306334778565 cpu, 0.0 io}
        rel#173:RelSubset#1.NONE.[0], best=null
                
rel#172:LogicalSort.NONE.[0](input=RelSubset#99,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#256:RelSubset#1.JDBC.BASEJDBC.[0], best=rel#255
                
rel#255:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#62,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={190.0 rows, 8390.306334778565 cpu, 0.0 io}
Set#2, type: RecordType(INTEGER contentViewsCount, BOOLEAN isExpired, 
VARCHAR(100) metadataPreviewUrl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assetTitle, VARCHAR(100) assetType, 
VARCHAR(100) contentType, VARCHAR(100) doi, VARCHAR(100) crmBpn, VARCHAR(100) 
doi0, VARCHAR(100) industry)
        rel#64:RelSubset#2.NONE.[], best=null
                
rel#63:LogicalJoin.NONE.[](left=RelSubset#61,right=RelSubset#62,condition==($9, 
$11),joinType=left), rowcount=1585.0, cumulative cost={inf}
                
rel#179:LogicalSort.NONE.[12](input=RelSubset#102,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={inf}
        rel#102:RelSubset#2.ENUMERABLE.[], best=rel#176
                
rel#101:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#96,right=RelSubset#99,condition==($9,
 $11),joinType=left), rowcount=1585.0, cumulative cost={2365.517018598809 rows, 
222.0 cpu, 0.0 io}
                rel#107:EnumerableMergeJoin.ENUMERABLE.[[9], 
[11]](left=RelSubset#103,right=RelSubset#105,condition==($9, 
$11),joinType=left), rowcount=1585.0, cumulative cost={2185.0 rows, 
31721.364072158547 cpu, 0.0 io}
                
rel#121:AbstractConverter.ENUMERABLE.[12](input=RelSubset#102,convention=ENUMERABLE,sort=[12]),
 rowcount=1585.0, cumulative cost={inf}
                
rel#176:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#109), 
rowcount=1585.0, cumulative cost={1943.5 rows, 360.5 cpu, 0.0 io}
                
rel#257:EnumerableSort.ENUMERABLE.[12](input=RelSubset#102,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={3528.5 rows, 747804.8777794265 cpu, 0.0 io}
                
rel#365:JdbcToEnumerableConverter.ENUMERABLE.[12](input=RelSubset#259), 
rowcount=1585.0, cumulative cost={3370.0 rows, 673060.4400014839 cpu, 0.0 io}
        rel#109:RelSubset#2.JDBC.BASEJDBC.[], best=rel#108
                
rel#108:JdbcJoin.JDBC.BASEJDBC.[](left=RelSubset#61,right=RelSubset#62,condition==($9,
 $11),joinType=left), rowcount=1585.0, cumulative cost={1785.0 rows, 202.0 cpu, 
0.0 io}
                
rel#258:JdbcSort.JDBC.BASEJDBC.[12](input=RelSubset#109,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={3211.5 rows, 672901.9400014839 cpu, 0.0 io}
        rel#120:RelSubset#2.ENUMERABLE.[12], best=rel#365
                
rel#121:AbstractConverter.ENUMERABLE.[12](input=RelSubset#102,convention=ENUMERABLE,sort=[12]),
 rowcount=1585.0, cumulative cost={inf}
                
rel#257:EnumerableSort.ENUMERABLE.[12](input=RelSubset#102,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={3528.5 rows, 747804.8777794265 cpu, 0.0 io}
                
rel#365:JdbcToEnumerableConverter.ENUMERABLE.[12](input=RelSubset#259), 
rowcount=1585.0, cumulative cost={3370.0 rows, 673060.4400014839 cpu, 0.0 io}
        rel#180:RelSubset#2.NONE.[12], best=null
                
rel#179:LogicalSort.NONE.[12](input=RelSubset#102,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={inf}
        rel#259:RelSubset#2.JDBC.BASEJDBC.[12], best=rel#258
                
rel#258:JdbcSort.JDBC.BASEJDBC.[12](input=RelSubset#109,sort0=$12,dir0=ASC), 
rowcount=1585.0, cumulative cost={3211.5 rows, 672901.9400014839 cpu, 0.0 io}
Set#3, type: RecordType(VARCHAR(100) semaphoreId, VARCHAR(100) name, 
VARCHAR(100) industryId)
        rel#65:RelSubset#3.JDBC.BASEJDBC.[], best=rel#7
                rel#7:JdbcTableScan.JDBC.BASEJDBC.[](table=[BASEJDBC, T3]), 
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
        rel#112:RelSubset#3.ENUMERABLE.[], best=rel#111
                
rel#111:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#65), 
rowcount=100.0, cumulative cost={110.0 rows, 111.0 cpu, 0.0 io}
Set#4, type: RecordType(VARCHAR(100) industry.semaphoreId, VARCHAR(100) 
industry.title)
        rel#67:RelSubset#4.NONE.[], best=null
                rel#66:LogicalProject.NONE.[](input=RelSubset#65,inputs=0..1), 
rowcount=100.0, cumulative cost={inf}
                
rel#181:LogicalSort.NONE.[0](input=RelSubset#114,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#114:RelSubset#4.ENUMERABLE.[], best=rel#178
                
rel#113:EnumerableProject.ENUMERABLE.[](input=RelSubset#112,inputs=0..1), 
rowcount=100.0, cumulative cost={210.0 rows, 311.0 cpu, 0.0 io}
                
rel#123:AbstractConverter.ENUMERABLE.[0](input=RelSubset#114,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#178:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#116), 
rowcount=100.0, cumulative cost={190.0 rows, 271.0 cpu, 0.0 io}
                
rel#260:EnumerableSort.ENUMERABLE.[0](input=RelSubset#114,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={290.0 rows, 9481.340371976183 cpu, 0.0 io}
                
rel#367:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#262), 
rowcount=100.0, cumulative cost={280.0 rows, 8560.306334778565 cpu, 0.0 io}
        rel#116:RelSubset#4.JDBC.BASEJDBC.[], best=rel#115
                
rel#115:JdbcProject.JDBC.BASEJDBC.[](input=RelSubset#65,inputs=0..1), 
rowcount=100.0, cumulative cost={180.0 rows, 261.0 cpu, 0.0 io}
                
rel#261:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#116,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={270.0 rows, 8550.306334778565 cpu, 0.0 io}
        rel#122:RelSubset#4.ENUMERABLE.[0], best=rel#367
                
rel#123:AbstractConverter.ENUMERABLE.[0](input=RelSubset#114,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#260:EnumerableSort.ENUMERABLE.[0](input=RelSubset#114,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={290.0 rows, 9481.340371976183 cpu, 0.0 io}
                
rel#367:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#262), 
rowcount=100.0, cumulative cost={280.0 rows, 8560.306334778565 cpu, 0.0 io}
        rel#182:RelSubset#4.NONE.[0], best=null
                
rel#181:LogicalSort.NONE.[0](input=RelSubset#114,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#262:RelSubset#4.JDBC.BASEJDBC.[0], best=rel#261
                
rel#261:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#116,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={270.0 rows, 8550.306334778565 cpu, 0.0 io}
Set#5, type: RecordType(INTEGER contentViewsCount, BOOLEAN isExpired, 
VARCHAR(100) metadataPreviewUrl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assetTitle, VARCHAR(100) assetType, 
VARCHAR(100) contentType, VARCHAR(100) doi, VARCHAR(100) crmBpn, VARCHAR(100) 
doi0, VARCHAR(100) industry, VARCHAR(100) industry.semaphoreId, VARCHAR(100) 
industry.title)
        rel#69:RelSubset#5.NONE.[], best=null
                
rel#68:LogicalJoin.NONE.[](left=RelSubset#64,right=RelSubset#67,condition==($12,
 $13),joinType=left), rowcount=25122.25, cumulative cost={inf}
                
rel#188:LogicalSort.NONE.[10](input=RelSubset#119,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={inf}
        rel#119:RelSubset#5.ENUMERABLE.[], best=rel#185
                
rel#118:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#102,right=RelSubset#114,condition==($12,
 $13),joinType=left), rowcount=25122.25, cumulative cost={39034.56840280354 
rows, 631.5 cpu, 0.0 io}
                rel#124:EnumerableMergeJoin.ENUMERABLE.[[12], 
[13]](left=RelSubset#120,right=RelSubset#122,condition==($12, 
$13),joinType=left), rowcount=25122.25, cumulative cost={30457.25 rows, 
681620.7463362624 cpu, 0.0 io}
                
rel#138:AbstractConverter.ENUMERABLE.[10](input=RelSubset#119,convention=ENUMERABLE,sort=[10]),
 rowcount=25122.25, cumulative cost={inf}
                
rel#185:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#126), 
rowcount=25122.25, cumulative cost={29599.475 rows, 2975.2250000000004 cpu, 0.0 
io}
                
rel#263:EnumerableSort.ENUMERABLE.[10](input=RelSubset#119,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={54721.725 rows, 1.8328869304803167E7 cpu, 
0.0 io}
                
rel#369:JdbcToEnumerableConverter.ENUMERABLE.[10](input=RelSubset#265), 
rowcount=25122.25, cumulative cost={52209.5 rows, 1.649627989682285E7 cpu, 0.0 
io}
        rel#126:RelSubset#5.JDBC.BASEJDBC.[], best=rel#125
                
rel#125:JdbcJoin.JDBC.BASEJDBC.[](left=RelSubset#109,right=RelSubset#116,condition==($12,
 $13),joinType=left), rowcount=25122.25, cumulative cost={27087.25 rows, 463.0 
cpu, 0.0 io}
                
rel#264:JdbcSort.JDBC.BASEJDBC.[10](input=RelSubset#126,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={49697.275 rows, 1.649376767182285E7 cpu, 
0.0 io}
        rel#137:RelSubset#5.ENUMERABLE.[10], best=rel#369
                
rel#138:AbstractConverter.ENUMERABLE.[10](input=RelSubset#119,convention=ENUMERABLE,sort=[10]),
 rowcount=25122.25, cumulative cost={inf}
                
rel#263:EnumerableSort.ENUMERABLE.[10](input=RelSubset#119,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={54721.725 rows, 1.8328869304803167E7 cpu, 
0.0 io}
                
rel#369:JdbcToEnumerableConverter.ENUMERABLE.[10](input=RelSubset#265), 
rowcount=25122.25, cumulative cost={52209.5 rows, 1.649627989682285E7 cpu, 0.0 
io}
        rel#189:RelSubset#5.NONE.[10], best=null
                
rel#188:LogicalSort.NONE.[10](input=RelSubset#119,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={inf}
        rel#265:RelSubset#5.JDBC.BASEJDBC.[10], best=rel#264
                
rel#264:JdbcSort.JDBC.BASEJDBC.[10](input=RelSubset#126,sort0=$10,dir0=ASC), 
rowcount=25122.25, cumulative cost={49697.275 rows, 1.649376767182285E7 cpu, 
0.0 io}
Set#6, type: RecordType(INTEGER contentViewsCount, VARCHAR(100) CRM_Account_ID, 
VARCHAR(100) CRM_Account_Name)
        rel#70:RelSubset#6.JDBC.BASEJDBC.[], best=rel#12
                rel#12:JdbcTableScan.JDBC.BASEJDBC.[](table=[BASEJDBC, T4]), 
rowcount=100.0, cumulative cost={100.0 rows, 101.0 cpu, 0.0 io}
        rel#129:RelSubset#6.ENUMERABLE.[], best=rel#128
                
rel#128:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#70), 
rowcount=100.0, cumulative cost={110.0 rows, 111.0 cpu, 0.0 io}
Set#7, type: RecordType(VARCHAR(100) crm_account.CRM_Account_ID, VARCHAR(100) 
crm_account.crm_account_name)
        rel#72:RelSubset#7.NONE.[], best=null
                rel#71:LogicalProject.NONE.[](input=RelSubset#70,exprs=[$1, 
$2]), rowcount=100.0, cumulative cost={inf}
                
rel#190:LogicalSort.NONE.[0](input=RelSubset#131,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#131:RelSubset#7.ENUMERABLE.[], best=rel#187
                
rel#130:EnumerableProject.ENUMERABLE.[](input=RelSubset#129,exprs=[$1, $2]), 
rowcount=100.0, cumulative cost={210.0 rows, 311.0 cpu, 0.0 io}
                
rel#140:AbstractConverter.ENUMERABLE.[0](input=RelSubset#131,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#187:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#133), 
rowcount=100.0, cumulative cost={190.0 rows, 271.0 cpu, 0.0 io}
                
rel#266:EnumerableSort.ENUMERABLE.[0](input=RelSubset#131,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={290.0 rows, 9481.340371976183 cpu, 0.0 io}
                
rel#371:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#268), 
rowcount=100.0, cumulative cost={280.0 rows, 8560.306334778565 cpu, 0.0 io}
        rel#133:RelSubset#7.JDBC.BASEJDBC.[], best=rel#132
                
rel#132:JdbcProject.JDBC.BASEJDBC.[](input=RelSubset#70,exprs=[$1, $2]), 
rowcount=100.0, cumulative cost={180.0 rows, 261.0 cpu, 0.0 io}
                
rel#267:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#133,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={270.0 rows, 8550.306334778565 cpu, 0.0 io}
        rel#139:RelSubset#7.ENUMERABLE.[0], best=rel#371
                
rel#140:AbstractConverter.ENUMERABLE.[0](input=RelSubset#131,convention=ENUMERABLE,sort=[0]),
 rowcount=100.0, cumulative cost={inf}
                
rel#266:EnumerableSort.ENUMERABLE.[0](input=RelSubset#131,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={290.0 rows, 9481.340371976183 cpu, 0.0 io}
                
rel#371:JdbcToEnumerableConverter.ENUMERABLE.[0](input=RelSubset#268), 
rowcount=100.0, cumulative cost={280.0 rows, 8560.306334778565 cpu, 0.0 io}
        rel#191:RelSubset#7.NONE.[0], best=null
                
rel#190:LogicalSort.NONE.[0](input=RelSubset#131,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={inf}
        rel#268:RelSubset#7.JDBC.BASEJDBC.[0], best=rel#267
                
rel#267:JdbcSort.JDBC.BASEJDBC.[0](input=RelSubset#133,sort0=$0,dir0=ASC), 
rowcount=100.0, cumulative cost={270.0 rows, 8550.306334778565 cpu, 0.0 io}
Set#8, type: RecordType(INTEGER contentViewsCount, BOOLEAN isExpired, 
VARCHAR(100) metadataPreviewUrl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assetTitle, VARCHAR(100) assetType, 
VARCHAR(100) contentType, VARCHAR(100) doi, VARCHAR(100) crmBpn, VARCHAR(100) 
doi0, VARCHAR(100) industry, VARCHAR(100) industry.semaphoreId, VARCHAR(100) 
industry.title, VARCHAR(100) crm_account.CRM_Account_ID, VARCHAR(100) 
crm_account.crm_account_name)
        rel#74:RelSubset#8.NONE.[], best=null
                
rel#73:LogicalJoin.NONE.[](left=RelSubset#69,right=RelSubset#72,condition==($10,
 $15),joinType=left), rowcount=398187.6625, cumulative cost={inf}
        rel#136:RelSubset#8.ENUMERABLE.[], best=rel#194
                
rel#135:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#119,right=RelSubset#131,condition==($10,
 $15),joinType=left), rowcount=398187.6625, cumulative cost={682603.4441639328 
rows, 3246.2250000000004 cpu, 0.0 io}
                rel#141:EnumerableMergeJoin.ENUMERABLE.[[10], 
[15]](left=RelSubset#137,right=RelSubset#139,condition==($10, 
$15),joinType=left), rowcount=398187.6625, cumulative cost={475899.4125 rows, 
1.6504840203157628E7 cpu, 0.0 io}
                
rel#194:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#143), 
rowcount=398187.6625, cumulative cost={465273.67874999996 rows, 40542.76625 
cpu, 0.0 io}
        rel#143:RelSubset#8.JDBC.BASEJDBC.[], best=rel#142
                
rel#142:JdbcJoin.JDBC.BASEJDBC.[](left=RelSubset#126,right=RelSubset#133,condition==($10,
 $15),joinType=left), rowcount=398187.6625, cumulative cost={425454.9125 rows, 
724.0 cpu, 0.0 io}
Set#9, type: RecordType(INTEGER contentviewscount, BOOLEAN isexpired, 
VARCHAR(100) metadatapreviewurl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assettitle, VARCHAR(100) assettype, 
VARCHAR(100) contenttype, VARCHAR(100) doi, NULL _metadata.status, VARCHAR(100) 
industry.title, VARCHAR(100) crm_account.crm_account_name)
        rel#76:RelSubset#9.NONE.[], best=null
                
rel#75:LogicalProject.NONE.[](input=RelSubset#74,inputs=0..9,exprs=[null:NULL, 
$14, $16]), rowcount=398187.6625, cumulative cost={inf}
        rel#145:RelSubset#9.ENUMERABLE.[], best=rel#196
                
rel#144:EnumerableProject.ENUMERABLE.[](input=RelSubset#136,inputs=0..9,exprs=[null:NULL,
 $14, $16]), rowcount=398187.6625, cumulative cost={863461.3412499999 rows, 
5216982.37875 cpu, 0.0 io}
                
rel#196:JdbcToEnumerableConverter.ENUMERABLE.[](input=RelSubset#147), 
rowcount=398187.6625, cumulative cost={783823.80875 rows, 4181694.45625 cpu, 
0.0 io}
        rel#147:RelSubset#9.JDBC.BASEJDBC.[], best=rel#146
                
rel#146:JdbcProject.JDBC.BASEJDBC.[](input=RelSubset#143,inputs=0..9,exprs=[null:NULL,
 $14, $16]), rowcount=398187.6625, cumulative cost={744005.0425 rows, 
4141875.69 cpu, 0.0 io}
Set#10, type: RecordType(INTEGER contentviewscount, BOOLEAN isexpired, 
VARCHAR(100) metadatapreviewurl, VARCHAR(100) format, VARCHAR(100) description, 
VARCHAR(100) language, VARCHAR(100) assettitle, VARCHAR(100) assettype, 
VARCHAR(100) contenttype, VARCHAR(100) doi, NULL _metadata.status, VARCHAR(100) 
industry.title, VARCHAR(100) crm_account.crm_account_name)
        rel#78:RelSubset#10.NONE.[], best=null
                
rel#77:LogicalFilter.NONE.[](input=RelSubset#76,condition=AND(=($1, ?0), 
OR(=($5, ?1), =($5, ?2)), OR(=($8, ?3), =($8, ?4)), =($9, ?5))), 
rowcount=559.9514003906249, cumulative cost={inf}
                
rel#151:LogicalProject.NONE.[](input=RelSubset#417,inputs=0..9,exprs=[null:NULL,
 $14, $16]), rowcount=559.9514003906249, cumulative cost={inf}
                
rel#212:LogicalProject.NONE.[](input=RelSubset#211,inputs=0..9,exprs=[null:NULL,
 $10, $11]), rowcount=559.9514003906249, cumulative cost={inf}
                
rel#226:LogicalSort.NONE.[9](input=RelSubset#78,sort0=$9,dir0=ASC), 
rowcount=559.9514003906249, cumulative cost={inf}
                
rel#336:LogicalProject.NONE.[9](input=RelSubset#575,inputs=0..9,exprs=[null:NULL,
 $14, $16]), rowcount=559.9514003906249, cumulative cost={inf}

{code}

> CyclicMetadataException thrown in complex JOIN
> ----------------------------------------------
>
>                 Key: CALCITE-5832
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5832
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: Ulrich Kramer
>            Priority: Major
>
> Adding the following unit test to {{JdbcAdapterTest}} reproduces the error
> {code:java}
>   @Test void testJdbcCyclicMetadata() throws Exception {
>     final String url = MultiJdbcSchemaJoinTest.TempDb.INSTANCE.getUrl();
>     Connection baseConnection = DriverManager.getConnection(url);
>     Statement baseStmt = baseConnection.createStatement();
>     baseStmt.execute("CREATE TABLE T1 (\n"
>         + "\"contentViewsCount\" INTEGER,\n" +
>         "\"isExpired\" BOOLEAN,\n" +
>         "\"metadataPreviewUrl\" VARCHAR(100),\n" +
>         "\"format\" VARCHAR(100),\n" +
>         "\"description\" VARCHAR(100),\n" +
>         "\"language\" VARCHAR(100),\n" +
>         "\"assetTitle\" VARCHAR(100),\n" +
>         "\"assetType\" VARCHAR(100),\n" +
>         "\"contentType\" VARCHAR(100),\n" +
>         "\"doi\" VARCHAR(100),\n" +
>         "\"crmBpn\" VARCHAR(100),\n" +
>         "PRIMARY KEY(\"doi\"))");
>     baseStmt.execute("CREATE TABLE T2 (\n"
>         + "\"doi\" VARCHAR(100),\n" +
>         "\"industry\" VARCHAR(100),\n" +
>         "PRIMARY KEY(\"doi\", \"industry\"))");
>     baseStmt.execute("CREATE TABLE T3 (\n"
>         + "\"semaphoreId\" VARCHAR(100),\n" +
>         "\"name\" VARCHAR(100),\n" +
>         "\"industryId\" VARCHAR(100),\n" +
>         "PRIMARY KEY(\"semaphoreId\"))");
>     baseStmt.execute("CREATE TABLE T4 (\n"
>         + "\"contentViewsCount\" INTEGER,\n" +
>         "\"CRM_Account_ID\" VARCHAR(100),\n" +
>         "\"CRM_Account_Name\" VARCHAR(100),\n" +
>         "PRIMARY KEY(\"CRM_Account_ID\"))");
>     baseStmt.close();
>     baseConnection.commit();
>     Properties info = new Properties();
>     info.put("model",
>         "inline:"
>             + "{\n"
>             + "  version: '1.0',\n"
>             + "  defaultSchema: 'BASEJDBC',\n"
>             + "  schemas: [\n"
>             + "     {\n"
>             + "       type: 'jdbc',\n"
>             + "       name: 'BASEJDBC',\n"
>             + "       jdbcDriver: '" + jdbcDriver.class.getName() + "',\n"
>             + "       jdbcUrl: '" + url + "',\n"
>             + "       jdbcCatalog: null,\n"
>             + "       jdbcSchema: null\n"
>             + "     }\n"
>             + "  ]\n"
>             + "}");
>     final Connection calciteConnection =
>         DriverManager.getConnection("jdbc:calcite:", info);
>     ResultSet rs = calciteConnection
>         .prepareStatement("SELECT \"_metadata.status\", \"doi\", 
> \"industry.title\", " +
>             "\"crm_account.crm_account_name\", \"assettitle\", 
> \"description\", \"assettype\", " +
>             "\"format\", \"contentviewscount\", \"metadatapreviewurl\", 
> \"language\", " +
>             "\"contenttype\", \"isexpired\" FROM (select\n" +
>             "  \"A\".\"contentViewsCount\" \"contentviewscount\",\n" +
>             "  \"A\".\"isExpired\" \"isexpired\",\n" +
>             "  \"A\".\"metadataPreviewUrl\" \"metadatapreviewurl\",\n" +
>             "  \"A\".\"format\" \"format\",\n" +
>             "  \"A\".\"description\" \"description\",\n" +
>             "  \"A\".\"language\" \"language\",\n" +
>             "  \"A\".\"assetTitle\" \"assettitle\",\n" +
>             "  \"A\".\"assetType\" \"assettype\",\n" +
>             "  \"A\".\"contentType\" \"contenttype\",\n" +
>             "  \"A\".\"doi\" \"doi\",\n" +
>             "  null \"_metadata.status\",\n" +
>             "  \"D\".\"industry.title\" \"industry.title\",\n" +
>             "  \"F\".\"crm_account.crm_account_name\" 
> \"crm_account.crm_account_name\"\n" +
>             "from \"T1\" \"A\"\n" +
>             "  left outer join \"T2\" \"B\"\n" +
>             "    on \"A\".\"doi\" = \"B\".\"doi\"\n" +
>             "  left outer join (\n" +
>             "    select\n" +
>             "      \"C\".\"semaphoreId\" \"industry.semaphoreId\",\n" +
>             "      \"C\".\"name\" \"industry.title\"\n" +
>             "    from \"T3\" \"C\"\n" +
>             "  ) \"D\"\n" +
>             "    on \"B\".\"industry\" = \"D\".\"industry.semaphoreId\"\n" +
>             "  left outer join (\n" +
>             "    select\n" +
>             "      \"E\".\"CRM_Account_ID\" 
> \"crm_account.CRM_Account_ID\",\n" +
>             "      \"E\".\"CRM_Account_Name\" 
> \"crm_account.crm_account_name\"\n" +
>             "    from \"T4\" \"E\"\n" +
>             "  ) \"F\"\n" +
>             "    on \"A\".\"crmBpn\" = \"F\".\"crm_account" +
>             ".CRM_Account_ID\")\n" +
>             "WHERE (\"isexpired\" = ?)\n" +
>             "AND (\"language\" IN (?, ?))\n" +
>             "AND (\"contenttype\" IN (?, ?))\n" +
>             "AND (\"doi\" IN (?))\n" +
>             "ORDER BY \"doi\" ASC\n" +
>             "LIMIT 500 OFFSET 0").executeQuery();
>     assertThat(rs.next(), is(true));
>     assertThat(rs.getObject(1), equalTo(20L));
>     assertThat(rs.next(), is(false));
>     rs.close();
>     calciteConnection.close();
>   }
> {code}
> The exception is triggered by adding the {{ORDER BY "doi"}} statement.
> I already tried several things. I caught the exception in 
> {{VolcanoPlanner::getCostOrInfinite}} and returned {{infCost}}. But this 
> leads to a {{StackOverflowException}} at another place.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to