Open poroszd opened 7 years ago
@dwayneberry should we make the suggested change?
FWIW, I compiled it myself (I had to update the thrift.version
to 0.10.0, e.g. org.apache.thrift.TSerializable wasn't even present in 0.9.3) and moved the data successfully.
Well, I was indeed missing something. This does not work for batch inserts (e.g. it will insert 'NULL' as string value for text columns).
This is because the prepared statement keeps track of only the string representation of the parameters (parmRep
), and the addBatch()
method tries to infer whether the parameter was null
using this string representation. I think you either have to handle null
specially in getQuery()
, or keep track of the type of the parameters.
@RalphLoen Any comment on this? You've been playing with Spark.
@poroszd Currently this code does not differentiate between empty string and NULL. It treats empty string as NULL.
To get your fix to work
@Override
public void setNull(int parameterIndex, int sqlType) throws SQLException { //logger.debug("Entered");
- throw new UnsupportedOperationException("Not supported yet," + " line:" + new Throwable().getStackTrace()[0].
- getLineNumber() + " class:" + new Throwable().getStackTrace()[0].getClassName() + " method:" + new Throwable().
- getStackTrace()[0].getMethodName());
+ parmRep[parameterIndex - 1] = "";
+ repCount++;
}
Should do it.
But really the longer term solution, if you want to be able to support an empty length string (edge case this fix will not support), we will need to add an additional flag
I'm using the jdbc interface to move data from Spark to MapD, but it does not work for
null
values, asMapDPreparedStatement.setNull()
is not implemented.Am I missing something, or it would be really this simple?