Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Weichen Xu <[email protected]>
  • Loading branch information
WeichenXu123 committed Nov 4, 2024
1 parent a62f50f commit 84dcb2e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mllib/src/main/scala/org/apache/spark/ml/util/SchemaUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,15 @@ private[spark] object SchemaUtils {
def getSchemaFieldType(schema: StructType, colName: String): DataType = {
getSchemaField(schema, colName).dataType
}

/**
* Check whether a certain column name exists in the schema.
* @param schema input schema
* @param colName column name, nested column name is supported.
*/
def checkSchemaFieldExist(schema: StructType, colName: String): Boolean = {
val colSplits = AttributeNameParser.parseAttributeName(colName)
val fieldOpt = schema.findNestedField(colSplits, resolver = SQLConf.get.resolver)
fieldOpt.isDefined
}
}

0 comments on commit 84dcb2e

Please sign in to comment.