dropPartition#

swordfish.function.dropPartition()#

Delete data from one or multiple partitions from a DFS database.

If tableName is specified: delete one or multiple partitions of the given table.

If tableName is not specified: delete one or multiple partitions of all tables with this partition.

Parameters:
  • dbHandle (Constant) – A DolphinDB database handle.

  • partitionPaths (Constant) –

    Can be specified in two ways:

    • By path: partitionPaths is a STRING scalar/vector indicating the path of one or multiple partitions. Each string must start with “/”. For composite partitions, the path must include all partition levels.

    • By condition: partitionPaths is a scalar or vector indicating the value(s) in the partitioning column. The system will drop all partitions containing these values. For composite partitions, partitionPaths is a tuple where each element is a filtering condition for each partition level (starting from the first level). If you do not want to apply filtering at a certain partition level, leave the corresponding element empty.

  • tableName (Constant) – A string indicating a table name. It can be left empty if the database chunk granularity is at DATABASE level (i.e., database: chunkGranularity = ‘DATABASE’). Otherwise, it is a required parameter.

  • forceDelete (Constant, optional) –

    A Boolean value. If set to true, the specified partition(s) will be deleted even if the partition(s) is recovering. The default value is false.

    Note

    When using the dropPartition function with forceDelete=false, the number of available replicas for the chunks involved in the transaction must be greater than or equal to the configured dfsReplicationFactor.

  • deleteSchema (Constant, optional) –

    A Boolean value. The default value is false, indicating that only the data in the selected partitions will be deleted, but the partition schema (which you can check with schema().partitionSchema) is kept. When the following conditions are satisfied, you can delete the schema of the selected partitions along with the partition data by setting deleteSchema to true:

    • There’s only one table in the database.

    • The partitioning type of the database is VALUE.

    • For composite partitions, the first level of partitioning type must be VALUE, and only the first level of partitions are selected for deletion.