Skip to content

Commit

Permalink
fix infinite case
Browse files Browse the repository at this point in the history
  • Loading branch information
zeotuan committed Jan 5, 2025
1 parent d69be53 commit 72e7c26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ object DataFrameExt {

@tailrec
def flatten(df: DataFrame): DataFrame = {
if (StructTypeHelpers.containComplexFields(df.schema)) {
if (StructTypeHelpers.containComplexFields(df.schema, flattenArrayType)) {
val renamedCols = StructTypeHelpers
.flattenSchema(df.schema, "", flattenArrayType)
.map { case (c, n) => c.as(sanitizeColName(n, delimiter)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ object StructTypeHelpers {
}
}

def containComplexFields(schema: StructType): Boolean = {
def containComplexFields(schema: StructType, isArrayComplex: Boolean): Boolean = {
schema.fields.exists {
case StructField(_, _: StructType, _, _) => true
case StructField(_, _: ArrayType, _, _) => true
case _ => false
case StructField(_, _: StructType, _, _) => true
case StructField(_, _: ArrayType, _, _) if isArrayComplex => true
case _ => false
}
}

Expand Down

0 comments on commit 72e7c26

Please sign in to comment.