Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

【Spark】Beanへのマッピングで例外が発生する

Sparkプログラムを書いていて、Beanへのマッピングで例外が発生しました。

エラーメッセージ

java.util.concurrent.ExecutionException: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 731, Column 72: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 731, Column 72: No applicable constructor/method found for actual parameters "long"; candidates are: "public static java.sql.Date org.apache.spark.sql.catalyst.util.DateTimeUtils.toJavaDate(int)"

原因

Beanのフィールドの型が、java.sql.Timestampではなく、java.util.Dateになっていた。SQL ServerのDateTime型にマッピングされるのは、java.sql.Timestamp

基本的なデータ型の使用 | Microsoft Docs