Forum: Building VoltDB Applications

Post: BigDecimal array in JSON Interface: Unable to match parameter array

BigDecimal array in JSON Interface: Unable to match parameter array
Sebastian
Feb 9, 2012
Hello,

I am trying to call an Insert procedure using the JSON interface. One of the Java run method parameters is a BigDecimal array.

The client calls this (abbreviated) URL:

http://
[IP]:8080/api/1.0/?Procedure=[procedure name]&Parameters=[...,"32.12"]

The response is:
{"status":-2,"appstatus":-128,"statusstring":"VOLTDB ERROR: PROCEDURE [procedure name] TYPE ERROR FOR PARAMETER 4: tryScalarMakeCompatible: Unable to match parameter array:java.math.BigDecimal to provided java.lang.String","appstatusstring":null,"exception":null,"results":[]}

A simple insert procedure (taking BigDecimal, as opposed to BigDecimal[]) works. What is the correct JSON representation of a BigDecimal array?

The only thing I have found in the VoltDB source code is a test case with an empty BigDecimal array (TestJSONInterface.java).

Thanks,
Sebastian
This was meant to look like
Sebastian
Feb 9, 2012
This was meant to look like this:
http://[IP]:8080/api/1.0/?Procedure=[procedure name]&Parameters=[...,["32.12"]]
VoltDB arrays are less flexible
jhugg
Feb 23, 2012
This was meant to look like this:
http://[IP]:8080/api/1.0/?Procedure=[procedure name]&Parameters=[...,["32.12"]]


We don't do much coercion of parameters if they are passed as arrays, i.e. arrays of strings don't get converted to arrays of decimals. I created a bug to improve the situation.
https://issues.voltdb.com/browse/ENG-2526
In the interim, you can take an array of strings for the param type, and do the conversion to BigDecimals in the stored procedure body.