Skip to content

Commit

Permalink
Dropped Spec column from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
souravbaner-da committed Jun 11, 2024
1 parent a5c8b54 commit aeef7ff
Showing 1 changed file with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,25 +561,26 @@ trait BronzeTransforms extends SparkSessionWrapper {
.withColumn(s"azure_attributes", SchemaTools.structToMap(scrubbedDF, s"azure_attributes"))
.withColumn(s"gcp_attributes", SchemaTools.structToMap(scrubbedDF, s"gcp_attributes"))
.withColumn("organization_id", lit(config.organizationId))
.drop("spec")
.verifyMinimumSchema(clusterSnapMinimumSchema)

val finalDF = df.schema.fields.find(_.name == "spec") match {
case Some(field) =>
field.dataType match {
case structType: StructType =>
val newFields = structType.fields.map { f =>
f.dataType match {
case _: StructType => SchemaTools.structToMap(df, s"spec.${f.name}").as(f.name)
case _ => col(s"spec.${f.name}").as(f.name)
}
}
df.withColumn("spec", struct(newFields: _*))
case _ => df
}
case None => df
}

finalDF
// val finalDF = df.schema.fields.find(_.name == "spec") match {
// case Some(field) =>
// field.dataType match {
// case structType: StructType =>
// val newFields = structType.fields.map { f =>
// f.dataType match {
// case _: StructType => SchemaTools.structToMap(df, s"spec.${f.name}").as(f.name)
// case _ => col(s"spec.${f.name}").as(f.name)
// }
// }
// df.withColumn("spec", struct(newFields: _*))
// case _ => df
// }
// case None => df
// }

df
.verifyMinimumSchema(clusterSnapMinimumSchema)

} else {
Expand Down

0 comments on commit aeef7ff

Please sign in to comment.