All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.johnsnowlabs.util.spark.SparkUtil.scala Maven / Gradle / Ivy

There is a newer version: 5.5.0
Show newest version
package com.johnsnowlabs.util.spark

import org.apache.spark.sql.Dataset

object SparkUtil {

  def retrieveColumnName(dataset: Dataset[_], annotatorType: String): String = {
    val structFields = dataset.schema.fields
      .filter(field => field.metadata.contains("annotatorType"))
      .filter(field => field.metadata.getString("annotatorType") == annotatorType)
    val columnNames = structFields.map(structField => structField.name)

    columnNames.head
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy