Class TableDefinition

java.lang.Object
com.datastax.astra.client.tables.definition.TableDefinition

public class TableDefinition extends Object
Definition of a table.
  • Constructor Details

    • TableDefinition

      public TableDefinition()
      Default constructor.
  • Method Details

    • addColumn

      public TableDefinition addColumn(String columnName, ColumnDefinition columnDefinition)
      Adds a column to the table definition.
      Parameters:
      columnName - the name of the column
      columnDefinition - the definition of the column
      Returns:
      the updated TableDefinition instance
      Throws:
      IllegalArgumentException - if columnName is null
    • addColumn

      public TableDefinition addColumn(String name, ColumnTypes type)
      Adds a column to the table with a specific type.
      Parameters:
      name - the name of the column
      type - the type of the column
      Returns:
      the updated TableDefinition instance
    • addColumnText

      public TableDefinition addColumnText(String name)
      Adds a text column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnAscii

      public TableDefinition addColumnAscii(String name)
      Adds an ascii column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnInt

      public TableDefinition addColumnInt(String name)
      Adds an integer column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnTimestamp

      public TableDefinition addColumnTimestamp(String name)
      Adds a timestamp column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnBoolean

      public TableDefinition addColumnBoolean(String name)
      Adds a boolean column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnBigInt

      public TableDefinition addColumnBigInt(String name)
      Adds a boolean column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnBlob

      public TableDefinition addColumnBlob(String name)
      Adds a blob column to the table.
      Parameters:
      name - the name of the column
      Returns:
      the updated TableDefinition instance
    • addColumnList

      public TableDefinition addColumnList(String name, ColumnTypes valueType)
      Adds a list column to the table.
      Parameters:
      name - the name of the column
      valueType - the type of the elements in the list
      Returns:
      the updated TableDefinition instance
    • addColumnSet

      public TableDefinition addColumnSet(String name, ColumnTypes valueType)
      Adds a set column to the table.
      Parameters:
      name - the name of the column
      valueType - the type of the elements in the set
      Returns:
      the updated TableDefinition instance
    • addColumnMap

      public TableDefinition addColumnMap(String name, ColumnTypes keyType, ColumnTypes valueType)
      Adds a map column to the table.
      Parameters:
      name - the name of the column
      keyType - the type of the keys in the map
      valueType - the type of the values in the map
      Returns:
      the updated TableDefinition instance
    • addColumnVector

      public TableDefinition addColumnVector(String name, ColumnDefinitionVector colDefVector)
      Adds a vector column to the table.
      Parameters:
      name - the name of the column
      colDefVector - the definition of the vector column
      Returns:
      the updated TableDefinition instance
    • addPartitionBy

      public TableDefinition addPartitionBy(String partitionKey)
      Adds a partition key to the table's primary key.
      Parameters:
      partitionKey - the name of the partition key column
      Returns:
      the updated TableDefinition instance
    • addPartitionSort

      public TableDefinition addPartitionSort(Sort column)
      Adds a sort column to the table's primary key.
      Parameters:
      column - the sort column to add
      Returns:
      the updated TableDefinition instance
      Throws:
      IllegalArgumentException - if column is null or invalid
    • partitionKey

      public TableDefinition partitionKey(String... partitionKeys)
      Sets the partition keys for the table.
      Parameters:
      partitionKeys - the partition keys
      Returns:
      the updated TableDefinition instance
      Throws:
      IllegalArgumentException - if any of the partition keys are not valid columns
    • clusteringColumns

      public TableDefinition clusteringColumns(Sort... clusteringColumns)
      Sets the clustering columns for the table.
      Parameters:
      clusteringColumns - the clustering columns
      Returns:
      the updated TableDefinition instance
      Throws:
      IllegalArgumentException - if any of the clustering columns are not valid columns
    • toString

      public String toString()
      Overrides:
      toString in class Object