Mongodb Reader and NumberDecimal data type.

Hello,
I tried to read NumberDecimal Object with the MongoDB reader node but getting following error:

ERROR MongoDB Reader 0:34 Execute failed: Invalid type 19 for field price

Is there any possibility to fetch Decimal objects like:

{“price” : NumberDecimal(“30.00”)}

from Mongodb to Knime Platform?

Hi,
Can you try

{"price" : { "$numberDecimal" : "30"}}

Kind regards
Alexander

Alexander, thank you for your replay but it looks like decimal objects are not supported by the MongoDB node. :frowning:

1 Like

Hi,
Can you post the error message? Maybe we can fix it.
Kind regards
Alexander

ERROR MongoDB Reader 0:34 Execute failed: Invalid type 19 for field price

Hi,
19 is the number for the decimal type: https://docs.mongodb.com/manual/reference/operator/query/type/. This means that the MongoDB driver gets the correct info that we want to query price with a condition that has a decimal, but it does not allow it for some reason. Unfortunately I do not know why that is. What happens if you just use {"price" : 30.0)}?
Kind regards,
Alexander

Hello.
If price is stored in mongodb as a string ({“price” : 30.0)}) reading from mongodb is no problem. If database is large converting from decimal to string values before read by knime is really problematic. (needs write permissions etc.)

Hi,
I do not understand this. {“price” : 30.0)} does not store the value as a string but as a number, isn’t it? String would be {“price” : “30.0”)}.
Kind regards,
Alexander

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.