【发布时间】:2018-12-26 08:28:09
【问题描述】:
我正在将Dataset<T> 转换为JavaRDD<T>。
我正在使用toJavaRDD() 方法。
转换完成后,我将在 RDD 上调用 collect() 方法。
当时产生以下异常:
CodeGenerator: failed to compile: org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 2114, Column 71: 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)"
org.codehaus.commons.compiler.CompileException: File 'generated.java', Line 2114, Column 71: 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)"
at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:11821)
我可以在eclipse控制台中看到generated.java文件的前1000行,该文件是由org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator生成的
但是如异常中所述,错误出现在 第 2114 行。
以下行在文件末尾的控制台中打印:[截断为 1000 行(总行数为 3381)]
我的问题是如何查看 generated.java 文件的所有行,以解决我的错误。
Spark 版本:2.3.0
如果您需要更多详细信息,请告诉我。
编辑:
generated.java 文件(1000 行中的几行)来自 Eclipse 控制台。
18/07/18 16:48:30 信息代码生成器:
/* 001 */ public java.lang.Object generate(Object[] references) {
/* 002 */ return new SpecificSafeProjection(references);
/* 003 */ }
/* 004 */
/* 005 */ class SpecificSafeProjection extends org.apache.spark.sql.catalyst.expressions.codegen.BaseProjection {
/* 006 */
/* 007 */ private Object[] references;
/* 008 */ private InternalRow mutableRow;
/* 009 */ private boolean resultIsNull;
/* 010 */ private long argValue;
/* 011 */ private boolean resultIsNull1;
/* 012 */ private long argValue1;
/* 013 */ private boolean resultIsNull2;
/* 014 */ private long argValue2;
/* 015 */ private boolean resultIsNull3;
/* 016 */ private long argValue3;
/* 017 */ private boolean resultIsNull4;
/* 018 */ private long argValue4;
/* 019 */ private boolean resultIsNull5;
/* 020 */ private long argValue5;
/* 021 */ private boolean resultIsNull6;
/* 022 */ private long argValue6;
/* 023 */ private boolean resultIsNull7;
/* 024 */ private long argValue7;
/* 025 */ private boolean resultIsNull8;
/* 026 */ private long argValue8;
/* 027 */ private boolean resultIsNull9;
/* 028 */ private long argValue9;
/* 029 */
/* 030 */ public SpecificSafeProjection(Object[] references) {
/* 031 */ this.references = references;
/* 032 */ mutableRow = (InternalRow) references[references.length - 1];
/* 033 */
/* 034 */
/* 035 */ }
/* 036 */
/* 037 */ public void initialize(int partitionIndex) {
/* 038 */
/* 039 */ }
/* 040 */
/* 041 */ public java.lang.Object apply(java.lang.Object _i) {
/* 042 */ InternalRow i = (InternalRow) _i;
/* 043 */
/* 044 */ com.sample.RuleParamsBean value274 = InitializeJavaBean(i);
/* 045 */ if (false) {
/* 046 */ mutableRow.setNullAt(0);
/* 047 */ } else {
/* 048 */
/* 049 */ mutableRow.update(0, value274);
/* 050 */ }
/* 051 */
/* 052 */ return mutableRow;
/* 053 */ }
/* 054 */
/* 055 */
/* 056 */ private void initializeJavaBean_4(InternalRow i, com.sample.RuleParamsBean javaBean) {
/* 057 */
/* 058 */
/* 059 */ boolean isNull20 = i.isNullAt(15);
/* 060 */ Decimal value20 = isNull20 ? null : (i.getDecimal(15, 5, 0));
/* 061 */ boolean isNull18 = false;
/* 062 */ org.apache.spark.sql.types.Decimal value18 = null;
/* 063 */ if (!false && isNull20) {
/* 064 */
/* 065 */ final org.apache.spark.sql.types.Decimal value21 = null;
/* 066 */ isNull18 = true;
/* 067 */ value18 = value21;
/* 068 */ } else {
/* 069 */
/* 070 */ final org.apache.spark.sql.types.Decimal value23 = false ? null : new org.apache.spark.sql.types.Decimal();
/* 071 */ org.apache.spark.sql.types.Decimal javaBean1 = value23;
/* 072 */ if (!false) {
/* 073 */
/* 074 */ }
/* 075 */ isNull18 = false;
/* 076 */ value18 = value23;
/* 077 */ }
/* 078 */ javaBean.setMESSAGE_NBR(value18);
/* 079 */
/* 080 */
/* 081 */ boolean isNull25 = i.isNullAt(86);
/* 082 */ UTF8String value25 = isNull25 ? null : (i.getUTF8String(86));
/* 083 */ boolean isNull24 = true;
/* 084 */ java.lang.String value24 = null;
/* 085 */ if (!isNull25) {
/* 086 */
/* 087 */ isNull24 = false;
/* 088 */ if (!isNull24) {
/* 089 */
/* 090 */ Object funcResult8 = null;
/* 091 */ funcResult8 = value25.toString();
【问题讨论】:
-
您可能有兴趣看看这里:stackoverflow.com/questions/48026060/…
-
@stefanobaghino 它是相似的,但在我的情况下,我没有使用 inferschema 选项。
-
@stefanobaghino 我正在从数据库表中加载数据。
标签: java eclipse apache-spark apache-spark-sql