db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rpau <r...@ac.upc.edu>
Subject Join with a null pointer when evaluating the on clause
Date Tue, 17 Mar 2015 17:06:55 GMT

I am transforming queries writen in a kind of relational algebra (I receive them as a JSON
object) into SQL using Derby. So, I have implemented a transformation that should do something
similar to the Derby SQL Parser (instantiatin the objects of org.apache.derby.impl.sql.compile).
Right now, I can build and run simple SELECT queries, LEFT/RIGHT-JOINS, but I have a problem
with the INNER-JOINs. I Instantiate them in this way:

node = new JoinNode(
			(org.apache.derby.impl.sql.compile.ResultSetNode) left.getVisitorResult(),
			(org.apache.derby.impl.sql.compile.ResultSetNode) right.getVisitorResult(), 
			(ValueNode) condition.getVisitorResult(), null, null, null,null, getContextManager());

I'm trying to emulate:
 SELECT T1.a, T1.b, T2.c FROM T1 JOIN T2 ON T1.a = T2.a

The query compiles perfectly and the result colums are perferttly inferred, but when it is
evaluated, the system produces a NullPointerException it check if the first row satisfies
the clause (T1.a = T2.a) from a . The clause is a simple BinaryRelationalOperation with 2
ColumReferences and the stack trace is as follows:

ERROR 38000: Se ha devuelto la excepción 'java.lang.NullPointerException' al evaluar una
	at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:290)
	at org.apache.derby.iapi.error.StandardException.unexpectedUserException(StandardException.java:509)
	at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:126)
	at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.getNextRowCore(ProjectRestrictResultSet.java:302)
	at org.apache.derby.impl.sql.execute.JoinResultSet.openCore(JoinResultSet.java:149)
	at org.apache.derby.impl.sql.execute.ProjectRestrictResultSet.openCore(ProjectRestrictResultSet.java:182)
	at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(BasicNoPutResultSetImpl.java:266)
	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:470)
	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:349)
	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1338)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1864)
	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1540)
	at org.apache.derby.impl.drda.DRDAStatement.execute(DRDAStatement.java:707)
	at org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(DRDAConnThread.java:4080)
	at org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:1043)
	at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:296)
Caused by: java.lang.NullPointerException
	at org.apache.derby.exe.acf55fc0a6x014cx2864xeb0bx000006520dc01.e0(Unknown Source)
	at org.apache.derby.impl.services.reflect.DirectCall.invoke(ReflectGeneratedClass.java:101)
	... 13 more

As you can see, I can't check exactly which is the error. However, I have detected that the
table T2 is has been never resolved (because T1 and T2 are function tables, and while T1 is
invoked, T2 is not ). Any ideas? I have been comparing my instantiation vs what derby instantiates
with the SQL Parser and I don't found any differences.



View raw message