|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object org.apache.spark.sql.types.DataType org.apache.spark.sql.types.StructType
public class StructType
:: DeveloperApi ::
A StructType
object can be constructed by
StructType(fields: Seq[StructField])
For a StructType
object, one or multiple StructField
s can be extracted by names.
If multiple StructField
s are extracted, a StructType
object will be returned.
If a provided name does not have a matching field, it will be ignored. For the case
of extracting a single StructField, a null
will be returned.
Example:
import org.apache.spark.sql._
val struct =
StructType(
StructField("a", IntegerType, true) ::
StructField("b", LongType, false) ::
StructField("c", BooleanType, false) :: Nil)
// Extract a single StructField.
val singleField = struct("b")
// singleField: StructField = StructField(b,LongType,false)
// This struct does not have a field called "d". null will be returned.
val nonExisting = struct("d")
// nonExisting: StructField = null
// Extract multiple StructFields. Field names are provided in a set.
// A StructType object will be returned.
val twoFields = struct(Set("b", "c"))
// twoFields: StructType =
// StructType(List(StructField(b,LongType,false), StructField(c,BooleanType,false)))
// Any names without matching fields will be ignored.
// For the case shown below, "d" will be ignored and
// it is treated as struct(Set("b", "c")).
val ignoreNonExisting = struct(Set("b", "c", "d"))
// ignoreNonExisting: StructType =
// StructType(List(StructField(b,LongType,false), StructField(c,BooleanType,false)))
A Row
object is used as a value of the StructType.
Example:
import org.apache.spark.sql._
val innerStruct =
StructType(
StructField("f1", IntegerType, true) ::
StructField("f2", LongType, false) ::
StructField("f3", BooleanType, false) :: Nil)
val struct = StructType(
StructField("a", innerStruct, true) :: Nil)
// Create a Row with the schema defined by struct
val row = Row(Row(1, 2, true))
// row: Row = {@link 1,2,true}
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface scala.PartialFunction |
---|
scala.PartialFunction.AndThen<A,B,C>, scala.PartialFunction.Lifted<A,B>, scala.PartialFunction.OrElse<A,B>, scala.PartialFunction.Unlifted<A,B> |
Nested classes/interfaces inherited from interface scala.collection.SeqLike |
---|
scala.collection.SeqLike.CombinationsItr, scala.collection.SeqLike.PermutationsItr |
Nested classes/interfaces inherited from interface scala.collection.TraversableLike |
---|
scala.collection.TraversableLike.WithFilter |
Nested classes/interfaces inherited from interface scala.collection.TraversableOnce |
---|
scala.collection.TraversableOnce.BufferedCanBuildFrom<A,Coll extends scala.collection.TraversableOnce<Object>>, scala.collection.TraversableOnce.FlattenOps<A>, scala.collection.TraversableOnce.ForceImplicitAmbiguity, scala.collection.TraversableOnce.MonadOps<A>, scala.collection.TraversableOnce.OnceCanBuildFrom<A> |
Constructor Summary | |
---|---|
StructType(StructField[] fields)
|
Method Summary | |
---|---|
StructField |
apply(int fieldIndex)
|
StructType |
apply(scala.collection.immutable.Set<String> names)
Returns a StructType containing StructField s of the given names, preserving the
original order of fields. |
StructField |
apply(String name)
Extracts a StructField of the given name. |
int |
defaultSize()
The default size of a value of the StructType is the total default sizes of all field types. |
int |
fieldIndex(String name)
Returns index of a given field |
String[] |
fieldNames()
Returns all field names in an array. |
StructField[] |
fields()
|
scala.collection.Iterator<StructField> |
iterator()
|
int |
length()
|
void |
printTreeString()
|
String |
simpleString()
Readable string representation for the type. |
String |
treeString()
|
Methods inherited from class org.apache.spark.sql.types.DataType |
---|
fromCaseClassString, fromJson, json, prettyJson, typeName |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface scala.collection.Seq |
---|
companion, seq |
Methods inherited from interface scala.PartialFunction |
---|
andThen, applyOrElse, isDefinedAt, lift, orElse, runWith |
Methods inherited from interface scala.Function1 |
---|
andThen$mcDD$sp, andThen$mcDF$sp, andThen$mcDI$sp, andThen$mcDJ$sp, andThen$mcFD$sp, andThen$mcFF$sp, andThen$mcFI$sp, andThen$mcFJ$sp, andThen$mcID$sp, andThen$mcIF$sp, andThen$mcII$sp, andThen$mcIJ$sp, andThen$mcJD$sp, andThen$mcJF$sp, andThen$mcJI$sp, andThen$mcJJ$sp, andThen$mcVD$sp, andThen$mcVF$sp, andThen$mcVI$sp, andThen$mcVJ$sp, andThen$mcZD$sp, andThen$mcZF$sp, andThen$mcZI$sp, andThen$mcZJ$sp, apply, apply$mcDD$sp, apply$mcDF$sp, apply$mcDI$sp, apply$mcDJ$sp, apply$mcFD$sp, apply$mcFF$sp, apply$mcFI$sp, apply$mcFJ$sp, apply$mcID$sp, apply$mcIF$sp, apply$mcII$sp, apply$mcIJ$sp, apply$mcJD$sp, apply$mcJF$sp, apply$mcJI$sp, apply$mcJJ$sp, apply$mcVD$sp, apply$mcVF$sp, apply$mcVI$sp, apply$mcVJ$sp, apply$mcZD$sp, apply$mcZF$sp, apply$mcZI$sp, apply$mcZJ$sp, compose, compose$mcDD$sp, compose$mcDF$sp, compose$mcDI$sp, compose$mcDJ$sp, compose$mcFD$sp, compose$mcFF$sp, compose$mcFI$sp, compose$mcFJ$sp, compose$mcID$sp, compose$mcIF$sp, compose$mcII$sp, compose$mcIJ$sp, compose$mcJD$sp, compose$mcJF$sp, compose$mcJI$sp, compose$mcJJ$sp, compose$mcVD$sp, compose$mcVF$sp, compose$mcVI$sp, compose$mcVJ$sp, compose$mcZD$sp, compose$mcZF$sp, compose$mcZI$sp, compose$mcZJ$sp, toString |
Methods inherited from interface scala.collection.SeqLike |
---|
$colon$plus, $plus$colon, combinations, contains, containsSlice, corresponds, diff, distinct, endsWith, indexOfSlice, indexOfSlice, indexWhere, indices, intersect, isEmpty, lastIndexOfSlice, lastIndexOfSlice, lastIndexWhere, lengthCompare, padTo, parCombiner, patch, permutations, reverse, reverseIterator, reverseMap, segmentLength, size, sortBy, sorted, sortWith, startsWith, thisCollection, toCollection, toSeq, toString, union, updated, view, view |
Methods inherited from interface scala.collection.IterableLike |
---|
canEqual, copyToArray, drop, dropRight, exists, find, foldRight, forall, foreach, grouped, head, reduceRight, sameElements, slice, sliding, sliding, take, takeRight, takeWhile, toIterable, toIterator, toStream, zip, zipAll, zipWithIndex |
Methods inherited from interface scala.collection.TraversableLike |
---|
$plus$plus, $plus$plus$colon, $plus$plus$colon, collect, dropWhile, filter, filterNot, flatMap, groupBy, hasDefiniteSize, headOption, init, inits, isTraversableAgain, last, lastOption, map, partition, repr, scan, scanLeft, scanRight, sliceWithKnownBound, sliceWithKnownDelta, span, splitAt, stringPrefix, tail, tails, to, toTraversable, withFilter |
Methods inherited from interface scala.collection.TraversableOnce |
---|
$colon$bslash, $div$colon, addString, addString, addString, aggregate, collectFirst, copyToArray, copyToArray, copyToBuffer, count, fold, foldLeft, max, maxBy, min, minBy, mkString, mkString, mkString, nonEmpty, product, reduce, reduceLeft, reduceLeftOption, reduceOption, reduceRightOption, reversed, sum, toArray, toBuffer, toIndexedSeq, toList, toMap, toSet, toVector |
Methods inherited from interface scala.collection.GenSeqLike |
---|
equals, hashCode, indexOf, indexOf, indexWhere, isDefinedAt, lastIndexOf, lastIndexOf, lastIndexWhere, prefixLength, startsWith |
Methods inherited from interface scala.collection.GenTraversableOnce |
---|
$div$colon$bslash |
Methods inherited from interface scala.collection.Parallelizable |
---|
par |
Methods inherited from interface scala.Product |
---|
productArity, productElement, productIterator, productPrefix |
Constructor Detail |
---|
public StructType(StructField[] fields)
Method Detail |
---|
public StructField[] fields()
public String[] fieldNames()
public StructField apply(String name)
StructField
of the given name. If the StructType
object does not
have a name matching the given name, null
will be returned.
name
- (undocumented)
public StructType apply(scala.collection.immutable.Set<String> names)
StructType
containing StructField
s of the given names, preserving the
original order of fields. Those names which do not have matching fields will be ignored.
names
- (undocumented)
public int fieldIndex(String name)
name
- (undocumented)
public String treeString()
public void printTreeString()
public StructField apply(int fieldIndex)
apply
in interface scala.collection.GenSeqLike<StructField,scala.collection.Seq<StructField>>
apply
in interface scala.collection.SeqLike<StructField,scala.collection.Seq<StructField>>
public int length()
length
in interface scala.collection.GenSeqLike<StructField,scala.collection.Seq<StructField>>
length
in interface scala.collection.SeqLike<StructField,scala.collection.Seq<StructField>>
public scala.collection.Iterator<StructField> iterator()
iterator
in interface scala.collection.GenIterableLike<StructField,scala.collection.Seq<StructField>>
iterator
in interface scala.collection.IterableLike<StructField,scala.collection.Seq<StructField>>
public int defaultSize()
defaultSize
in class DataType
public String simpleString()
DataType
simpleString
in class DataType
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |