We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 949d6bb commit eca7d04Copy full SHA for eca7d04
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/types/dataTypes.scala
@@ -292,6 +292,15 @@ object StructType {
292
case class StructType(fields: Seq[StructField]) extends DataType {
293
require(StructType.validateFields(fields), "Found fields with the same name.")
294
295
+ def apply(name: String): StructField = {
296
+ fields.find(f => f.name == name).orNull
297
+ }
298
+
299
+ def apply(names: String*): StructType = {
300
+ val nameSet = names.toSet
301
+ StructType(fields.filter(f => nameSet.contains(f.name)))
302
303
304
def toAttributes = fields.map(f => AttributeReference(f.name, f.dataType, f.nullable)())
305
306
def schemaString: String = {
0 commit comments