[ https://issues.apache.org/jira/browse/SPARK-32619?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Manjay Kumar updated SPARK-32619: --------------------------------- Comment: was deleted (was: Please find the code snippet. val sparkSession:SparkSession = SparkSession.builder().master("local[*]").getOrCreate() val dataframe = sparkSession.read.json("test.json") import sparkSession.implicits._ val dealList:Dataset[FinancingDealUnpaid] = dataframe.as[FinancingDealUnpaid] input 1: { "backDealUID": "xyxyyx", "sourceApplicationCode": "asdsad", "facilityUnpaids": [{ "facilityId": "asdjadj", "sourceApplicationCode": "asddsa", "facilityFeeUnpaids": [{ "feeId": "asddsaasd", "unpaids": [ { "unpaidId": "asddsa", "unpaidDate": "asdas", "unpaidSrc": "asd", "amount": 9999999, "currency": "asdasd", "scheduledFlowDate": "asddsa", "technicalUnpaidReasonCode": "asddsadasdsad" } ] }] }] } Input 2: {{ "backDealUID": "uaygdia", "sourceApplicationCode": "dvsd", "dealFeeUnpaids": [{ "feeId": "sdfsdf", "unpaids": [{ "unpaidId": "sdfsdf", "unpaidDate": "sdfsdf", "unpaidSrc": "sfdsd", "amount": 234324, "currency": "dzcsdf", "scheduledFlowDate": "erexdz", "technicalUnpaidReasonCode": "zdc", "repayments": [ { "amount": 23423, "currency": "eaas", "paymentDate": "saff" } ] }] }] } input 2 has unpaid and input doesnt have unpaid while casting for one dataset it should be null for unpaid Exception log:: but it is failing with Exception in thread "main" org.apache.spark.sql.AnalysisException: No such struct field repayments in amt , ....... what should be the fix ?? Ideally , it should mark repayment object as null incase of no data input fields in input data. ) > converting dataframe to dataset for the json schema > --------------------------------------------------- > > Key: SPARK-32619 > URL: https://issues.apache.org/jira/browse/SPARK-32619 > Project: Spark > Issue Type: Bug > Components: Spark Core > Affects Versions: 2.4.3 > Reporter: Manjay Kumar > Priority: Minor > > have a schema > > { > Details :[{ > phone : "98977999" > contacts: [{ > name:"manjay" > ---------- has missing street block in json > ]} > ]} > > } > > Case class , based on schema > case class Details ( > phone : String, > contacts : Array[Adress] > ) > > case class Adress( > name : String > street : String > > ) > > > this throws : No such struct field street - Analysis exception. > > dataframe.as[Details] > > Is this a bug ?? or there is a resolution for this. > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org