dynamobi/dynamobi — Issue #258: [LDB-63] Assertion error in ReduceDecimalsRule
Author: dynamobi-build
Created: 2011-12-30 02:24:58+00:00
State: open
Labels: LDB

[reporter="elin", created="Fri, 14 Apr 2006 12:13:23 -0500 (GMT-05:00)"]
Depending on the ordering of the tables in the from list, this may not occur. It doesn't happen for the ordering which is commented out below.

The stack trace:

Error: java.lang.AssertionError: null (state=,code=0)

net.sf.farrago.jdbc.FarragoJdbcUtil$FarragoSqlException: java.lang.AssertionError: null

at org.eigenbase.rel.ReduceDecimalsRule$BinaryArithmeticExpander.expand(ReduceDecimalsRule.java:801)

at org.eigenbase.rel.ReduceDecimalsRule$Translator.reduceNode(ReduceDecimalsRule.java:316)

at org.eigenbase.rel.ReduceDecimalsRule$Translator.reduceTree(ReduceDecimalsRule.java:296)

at org.eigenbase.rel.ReduceDecimalsRule$Translator.reduceDecimals(ReduceDecimalsRule.java:243)

at org.eigenbase.rel.ReduceDecimalsRule.onMatch(ReduceDecimalsRule.java:162)

at com.disruptivetech.farrago.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:131)

at com.disruptivetech.farrago.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:391)

at org.eigenbase.oj.stmt.OJPreparingStmt.optimize(OJPreparingStmt.java:282)

at net.sf.farrago.query.FarragoPreparingStmt.optimize(FarragoPreparingStmt.java:629)

at org.eigenbase.oj.stmt.OJPreparingStmt.prepareSql(OJPreparingStmt.java:253)

at net.sf.farrago.query.FarragoPreparingStmt.prepare(FarragoPreparingStmt.java:240)

at net.sf.farrago.db.FarragoDatabase$2.initializeEntry(FarragoDatabase.java:784)

at net.sf.farrago.util.FarragoObjectCache.pin(FarragoObjectCache.java:157)

at net.sf.farrago.db.FarragoDatabase.prepareStmtImpl(FarragoDatabase.java:794)

at net.sf.farrago.db.FarragoDatabase.prepareStmt(FarragoDatabase.java:674)

at net.sf.farrago.db.FarragoDbSession.prepareImpl(FarragoDbSession.java:829)

at net.sf.farrago.db.FarragoDbSession.prepare(FarragoDbSession.java:771)

at net.sf.farrago.db.FarragoDbStmtContext.prepare(FarragoDbStmtContext.java:108)

at net.sf.farrago.jdbc.engine.FarragoJdbcEngineStatement.execute(FarragoJdbcEngineStatement.java:105)

at sqlline.SqlLine$Commands.execute(Unknown Source)

at sqlline.SqlLine$Commands.sql(Unknown Source)

at sqlline.SqlLine.dispatch(Unknown Source)

at sqlline.SqlLine.begin(Unknown Source)

at sqlline.SqlLine.mainWithInputRedirection(Unknown Source)

at sqlline.SqlLine.main(Unknown Source)

0: jdbc:luciddb:>

To reproduce: (creating/setting up the tables shouldn't take too long (a few minutes or so)

create schema PGE;

create foreign data wrapper mssql_jdbc

library '/home/elin/open/luciddb/plugin/FarragoMedJdbc3p.jar'

language java;

create server mssql_server

foreign data wrapper mssql_jdbc

options(

url 'jdbc:jtds:sqlserver://akela.lucidera.com:1433',

user_name 'sa',

password 'ketajo',

qualifying_catalog_name 'pge',

table_types 'TABLE',

driver_class 'net.sourceforge.jtds.jdbc.Driver'

);

create schema PGE_REMOTE;

import foreign schema "dbo" from server mssql_server into PGE_REMOTE;

create table PGE.CUST_SERV_ACCT(CUST_SERV_ACCT_KEY DECIMAL(10,0),

CU_ID DECIMAL(10,0),

CU_TYP_IND CHAR(1),

CUOR_CUST_NM VARCHAR(50),

ORGDTL_STR_ID_TXT VARCHAR(10),

ORGDTL_NM VARCHAR(50),

ORGDTL_DBA_NM VARCHAR(18),

CUIN_LST_NM VARCHAR(25),

CUIN_FST_NM VARCHAR(25),

CUIN_MID_INIT_TXT CHAR(1),

CA_ID DECIMAL(10,0),

MAIL_ADDR_ID DECIMAL(10,0),

SITE_ID DECIMAL(10,0),

SERV_ADDR VARCHAR(40),

MNCPLT_NM VARCHAR(25),

ST_CD CHAR(2),

ZIP_CD_NUM CHAR(5),

CO_CD CHAR(3),

GEOG_KEY DECIMAL(10,0),

SITUSE_CD CHAR(2),

SAA_ID DECIMAL(10,0),

SAA_SEQ_NUM DECIMAL(5,0),

SRVPLN_KEY DECIMAL(10,0),

CYC_FREQY_CD CHAR(2),

ACYC_NUM CHAR(2),

CNTLUT_NUM DECIMAL(10,0),

IS_DWLGS_VAL DECIMAL(5,0),

SERV_SIC_CD CHAR(4),

BU_CD CHAR(3),

UTIL_TYP_CD CHAR(2),

SAA_SPLINSTL_INDCR CHAR(1),

SAA_CLRG_ACCT_ID DECIMAL(10,0),

SAA_ST_TX_EXM_INDC CHAR(1),

IS_SERV_INSTLD_DT TIMESTAMP,

RCD_EFF_DT TIMESTAMP,

RCD_END_DT TIMESTAMP,

PROC_BAT_ID DECIMAL(10,0))

;

create table PGE.GEOG(GEOG_KEY DECIMAL(10,0),

DPT_CD CHAR(3),

RVTWN_CD CHAR(3),

RVTWN_DESC VARCHAR(30),

GEOG_CNTY_CD CHAR(2),

GEOG_CNTY_DESC VARCHAR(30),

ST_CD CHAR(2),

ST_DESC VARCHAR(30),

PROC_BATCH_ID VARCHAR(10))

;

create table PGE.REVN_DTL_RAND(CUST_SERV_ACCT_KEY DECIMAL(10,0),

GEOG_KEY DECIMAL(10,0),

SRVPLN_KEY DECIMAL(10,0),

REVN_YR_MO DECIMAL(6,0),

USG_VAL DOUBLE,

USG_BILL_THERM DOUBLE,

USG_BILL_KWH DOUBLE,

USGC_BILL_KW_VAL DOUBLE,

RSD_SVC_BILG_AMT DOUBLE,

RSD_ST_SLSTX_AMT DOUBLE,

RSD_TRSPT_CHRG_AMT DOUBLE,

RSD_BALG_CHRG_AMT DOUBLE,

RSD_TOP_SRCHRG_AMT DOUBLE,

RSD_CCOGA_AMT DOUBLE,

RSD_CCOGC_AMT DOUBLE,

RSD_CUST_CHRG_AMT DOUBLE,

RSD_DMND_CHRG_AMT DOUBLE,

RSD_CU_CNT DECIMAL(5,0),

SAS_FNL_BIL_INDCR CHAR(1),

SAS_TYP_CD CHAR(1),

USG_DAYS_NUM DECIMAL(5,0),

USG_STRT_DT TIMESTAMP,

USG_END_DT TIMESTAMP,

CISPD_DT TIMESTAMP,

PROC_BAT_ID DECIMAL(10,0))

;

create table PGE.REVN_PRD(REVN_YR_MO DECIMAL(6,0),

REVN_YR_MO_DESC VARCHAR(14),

REVN_MO DECIMAL(2,0),

REVN_MO_DESC VARCHAR(9),

REVN_YR DECIMAL(4,0),

REVN_QTR CHAR(1),

REVN_QTR_YR CHAR(7),

REVN_QTR_YR_DESC VARCHAR(20),

USER_ID CHAR(4))

;

create table PGE.SERV_PLAN(SRVPLN_KEY DECIMAL(10,0),

SRVPLN_ID DECIMAL(10,0),

SRVPLN_NM VARCHAR(25),

SPO_ID DECIMAL(10,0),

SPO_NM VARCHAR(25),

BU_CD CHAR(3),

BU_DESC VARCHAR(30),

RC_CD CHAR(2),

RC_DESC VARCHAR(30),

PROC_BAT_ID DECIMAL(10,0))

;

insert into PGE.CUST_SERV_ACCT select * from PGE_REMOTE."csa";

insert into PGE.GEOG select * from PGE_REMOTE."g";

insert into PGE.REVN_DTL_RAND select * from PGE_REMOTE."rdr";

insert into PGE.REVN_PRD select * from PGE_REMOTE."rp";

insert into PGE.SERV_PLAN select * from PGE_REMOTE."sp";

--- Here's the query in question:

explain plan for

SELECT AL3.SRVPLN_KEY, AL3.SRVPLN_ID,

AL3.SRVPLN_NM, AL3.SPO_ID, AL3.SPO_NM,

AL3.BU_CD, AL3.RC_CD, AL3.PROC_BAT_ID,

AL4.REVN_YR_MO,

MAX(AL5.USG_DAYS_NUM),

MAX(AL5.RSD_SVC_BILG_AMT), MAX(AL5.USGC_BILL_KW_VAL),

MAX(AL5.USG_BILL_KWH), MAX(AL5.RSD_DMND_CHRG_AMT),

MAX(AL5.RSD_CUST_CHRG_AMT), MAX(AL5.RSD_CCOGC_AMT),

MAX(AL5.RSD_CCOGA_AMT), MAX(AL5.RSD_TOP_SRCHRG_AMT),

MAX(AL5.RSD_BALG_CHRG_AMT), MAX(AL5.RSD_ST_SLSTX_AMT),

MAX(AL5.RSD_TRSPT_CHRG_AMT)

FROM

-- PGE.CUST_SERV_ACCT AL1,

-- PGE.GEOG AL2,

-- PGE.SERV_PLAN AL3,

-- PGE.REVN_PRD AL4,

-- PGE.REVN_DTL_RAND AL5

PGE.CUST_SERV_ACCT AL1,

PGE.REVN_DTL_RAND AL5,

PGE.SERV_PLAN AL3,

PGE.REVN_PRD AL4,

PGE.GEOG AL2

WHERE (AL5.REVN_YR_MO=AL4.REVN_YR_MO

AND AL2.GEOG_KEY=AL5.GEOG_KEY AND AL3.SRVPLN_KEY=AL5.SRVPLN_KEY

AND AL1.CUST_SERV_ACCT_KEY=AL5.CUST_SERV_ACCT_KEY) AND

(AL2.ST_CD='IN' AND AL2.GEOG_CNTY_DESC='LAPORTE'

AND AL2.RVTWN_DESC='LA PORTE' AND AL4.REVN_YR=1995

AND AL3.SPO_NM='ELE SPACE HEAT - RES'

AND AL3.SRVPLN_NM='ELEC - RESIDENTIAL')

GROUP BY AL3.SRVPLN_KEY, AL3.SRVPLN_ID,

AL3.SRVPLN_NM, AL3.SPO_ID, AL3.SPO_NM,

AL3.BU_CD, AL3.RC_CD, AL3.PROC_BAT_ID, AL4.REVN_YR_MO

ORDER BY 13

;