Class StructType
- java.lang.Object
-
- com.snowflake.snowpark_java.types.DataType
-
- com.snowflake.snowpark_java.types.StructType
-
- All Implemented Interfaces:
Serializable
,Iterable<StructField>
public class StructType extends DataType implements Iterable<StructField>
StructType data type, represents table schema.- Since:
- 0.9.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description StructType(StructField[] fields)
Creates a StructType object based on the given Array of StructField.StructType(StructType other)
Clones the given StructType object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StructType
add(StructField field)
Creates new StructType by appending the given StructField to the end of this StructType.StructType
add(String name, DataType dataType)
Creates new StructType by appending a new StructField with the given info to the end of this StructType.StructType
add(String name, DataType dataType, boolean nullable)
Creates new StructType by appending a new StructField with the given info to the end of this StructType.static StructType
create(StructField... fields)
Creates a StructType object based on the given StructFieldboolean
equals(Object other)
Verifies if a StructType equals to this one.StructField
get(int index)
Retrieves the StructField object from the given index.int
hashCode()
Calculates the hash code of this StructType Object.Iterator<StructField>
iterator()
Creates an Iterator of StructFields.String[]
names()
Retrieves the names of StructField.Optional<StructField>
nameToField(String name)
Retrieves the corresponding StructField object of the given name.void
printTreeString()
Prints the schema StructType content in a tree structure diagram.int
size()
Counts the number of StructFields in this StructType object.String
toString()
Generates a String value to represent this StructType.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
StructType
public StructType(StructType other)
Clones the given StructType object.- Parameters:
other
- A StructType object- Since:
- 0.9.0
-
StructType
public StructType(StructField[] fields)
Creates a StructType object based on the given Array of StructField.- Parameters:
fields
- An Array of StructField- Since:
- 0.9.0
-
-
Method Detail
-
create
public static StructType create(StructField... fields)
Creates a StructType object based on the given StructField- Parameters:
fields
- A list of StructFields- Returns:
- A new StructType object
- Since:
- 0.9.0
-
names
public String[] names()
Retrieves the names of StructField.- Returns:
- An array of String representing the names of StructFields
- Since:
- 0.9.0
-
size
public int size()
Counts the number of StructFields in this StructType object.- Returns:
- An int number
- Since:
- 0.9.0
-
iterator
public Iterator<StructField> iterator()
Creates an Iterator of StructFields.- Specified by:
iterator
in interfaceIterable<StructField>
- Returns:
- An Iterator of StructField
- Since:
- 0.9.0
-
get
public StructField get(int index)
Retrieves the StructField object from the given index.- Parameters:
index
- An int number representing the index of StructField- Returns:
- The StructField object at the given index.
- Since:
- 0.9.0
-
toString
public String toString()
Generates a String value to represent this StructType.
-
add
public StructType add(StructField field)
Creates new StructType by appending the given StructField to the end of this StructType. This function doesn't modify this StructType object, but create and return a new one.- Parameters:
field
- The StructField object being appended.- Returns:
- A new StructType object
- Since:
- 0.9.0
-
add
public StructType add(String name, DataType dataType, boolean nullable)
Creates new StructType by appending a new StructField with the given info to the end of this StructType. This function doesn't modify this StructType object, but create or return a new one.- Parameters:
name
- The name of the StructField object being appended.dataType
- The data type of the StructField object being appended.nullable
- Whether the new StructField is nullable or not- Returns:
- A new StructType object
- Since:
- 0.9.0
-
add
public StructType add(String name, DataType dataType)
Creates new StructType by appending a new StructField with the given info to the end of this StructType. The new StructField is nullable. This function doesn't modify this StructType object, but create and return a new one.- Parameters:
name
- The name of the StructField object being appended.dataType
- The data type of the StructField object being appended.- Returns:
- A new StructType object
- Since:
- 0.9.0
-
nameToField
public Optional<StructField> nameToField(String name)
Retrieves the corresponding StructField object of the given name.- Parameters:
name
- The name of StructField- Returns:
- An Optional StructField object.
- Since:
- 0.9.0
-
equals
public boolean equals(Object other)
Verifies if a StructType equals to this one.
-
hashCode
public int hashCode()
Calculates the hash code of this StructType Object.
-
printTreeString
public void printTreeString()
Prints the schema StructType content in a tree structure diagram.- Since:
- 0.9.0
-
-