StructType
Defined in: types/struct.ts:36
Mirrors Spark’s StructType and StructField for schema inspection.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StructType(fields?): StructType;Defined in: types/struct.ts:39
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
fields | StructField[] | [] |
Returns
Section titled “Returns”StructType
Properties
Section titled “Properties”fields
Section titled “fields”readonly fields: readonly StructField[];Defined in: types/struct.ts:37
Accessors
Section titled “Accessors”fieldNames
Section titled “fieldNames”Get Signature
Section titled “Get Signature”get fieldNames(): string[];Defined in: types/struct.ts:49
Get field names.
Returns
Section titled “Returns”string[]
length
Section titled “length”Get Signature
Section titled “Get Signature”get length(): number;Defined in: types/struct.ts:59
Number of top-level fields.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”add( name, dataType, nullable?): StructType;Defined in: types/struct.ts:44
Add a field and return a new StructType.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
name | string | undefined |
dataType | string | undefined |
nullable | boolean | true |
Returns
Section titled “Returns”StructType
getField()
Section titled “getField()”getField(name): StructField | undefined;Defined in: types/struct.ts:54
Look up a field by name.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
name | string |
Returns
Section titled “Returns”StructField | undefined
toDDL()
Section titled “toDDL()”toDDL(): string;Defined in: types/struct.ts:85
Return a DDL-formatted schema string, e.g. “name string, age integer”. Compatible with DataFrameReader.schema().
Returns
Section titled “Returns”string
toString()
Section titled “toString()”toString(): string;Defined in: types/struct.ts:77
Returns
Section titled “Returns”string
treeString()
Section titled “treeString()”treeString(): string;Defined in: types/struct.ts:69
Pretty-print the schema in Spark’s tree format: root |— name: string (nullable = true) |— age: integer (nullable = false)
Returns
Section titled “Returns”string
fromProto()
Section titled “fromProto()”static fromProto(proto): StructType;Defined in: types/struct.ts:95
Build a StructType from a Spark Connect DataType proto (schema response).
The proto is a plain object with struct.fields array.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
proto | Record<string, unknown> |
Returns
Section titled “Returns”StructType