Bigdecimal in cascading-jdbc

27 views
Skip to first unread message

Rajesh Nakkana

unread,
Jan 29, 2014, 8:25:59 PM1/29/14
to cascadi...@googlegroups.com
I am using cascading-jdbc from conjars and need to store decimal value in mysql. Has anyone tried to store bigdecimal values in the database.

I get following error

Caused by: java.lang.IllegalArgumentException: cannot map type class java.math.BigDecimal to a sql type

at cascading.jdbc.InternalTypeMapping.sqltypeForClass(InternalTypeMapping.java:131)

at cascading.jdbc.TableDesc.completeFromFields(TableDesc.java:231)


Thanks,
Rajesh

Andre Kelpe

unread,
Jan 29, 2014, 8:48:41 PM1/29/14
to cascadi...@googlegroups.com
What does your TableDesc look like? How do you interact with the JDBCTap and JDBCScheme? You seem to not provide any type information upfront, so cascading-jdbc tries to guess the SQL types based on your fields. You can avoid that, by telling the TableDesc your types like so:

https://github.com/Cascading/cascading-jdbc/blob/2.5/cascading-jdbc-core/src/test/java/cascading/jdbc/JDBCTestingBase.java#L157

- André


--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascading-use...@googlegroups.com.
To post to this group, send email to cascadi...@googlegroups.com.
Visit this group at http://groups.google.com/group/cascading-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/cascading-user/de64c1db-79c0-484b-aa04-e34672d21c41%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
André Kelpe
an...@concurrentinc.com
http://concurrentinc.com

Rajesh Nakkana

unread,
Jan 29, 2014, 10:05:23 PM1/29/14
to cascadi...@googlegroups.com
Thanks Andre. It works after fixing the TableDesc.

-Rajesh

Nagaraju Magati

unread,
Jul 29, 2015, 5:56:25 PM7/29/15
to cascading-user, ake...@concurrentinc.com
Andre,

I am seeing the same issue with version 3.0. I made sure that TableDesc and JDBCScheme are good. I looked at the InternalTypeMapping.java file and BigDecimal.class is not added in TYPES. Does it mean DECIMAL and NUMERIC types are not supported in cascading-jdbc yet?

Thanks for your help.

Nagaraju

Andre Kelpe

unread,
Jul 30, 2015, 4:20:16 AM7/30/15
to cascading-user
Hi,

If you pass a fields instance with type information to the JDBCScheme/JDBCTap, it will do the right thing. You can pass your own types, that handle NUMERIC and DECIMAL correctly. Writing them is not difficult:

http://docs.cascading.org/cascading/3.0/userguide/ch04-tuple-fields.html#field-coercion

http://docs.cascading.org/cascading/3.0/javadoc/cascading-core/cascading/tuple/type/CoercibleType.html

- André
Reply all
Reply to author
Forward
0 new messages