我试图找到与我的json文件的每一行匹配的case类。我有错误:
Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve '`result`' due to data type mismatch: cannot cast
ArrayType(StructType(StructField(hop,LongType,true), StructField(result,ArrayType(StructType(StructField(from,StringType,true), StructField(rtt,DoubleType,true), StructField(size,LongType,true), StructField(ttl,LongType,true)),true),true)),true) ArrayType(StructType(StructField(result,ArrayType(StructType(StructField(rtt,DoubleType,true), StructField(ttl,IntegerType,true), StructField(from,StringType,true), StructField(size,IntegerType,true)),true),true), StructField(hop,IntegerType,true)),true);
和我的案例课是:
case class Result(
result: Seq[Result1],
hop: Int)
case class Result1(
rtt: Double,
ttl: Int,
from: String,
size: Int)
case class RootInterface(
dst_name: String,
from: String,
prb_id: BigInt,
msm_id: BigInt,
timestamp: BigInt,
result: Seq[Result])
唯一的区别是两种模式中的顺序,这是导致异常的问题吗? 案例类Result映射异常中的result属性。
答案 0 :(得分:0)
是的,顺序很重要!试试这个比较模式:
C:\Users\admin\Documents\Enviorments\django_1\Scripts\activate
这应该显示 false 。使用它来比较您的架构。