addRangePartitions(dbHandle, newRanges, [level=0], [locations])


dbHandle is a database handle.

newRanges is a vector indicating new partitions. The elements in the vector must be in ascending order. The first element must be the same as the last element or the original partition scheme.

level is a nonnegative integer. For a partitioned database with COMPO domain, we need to specify the level of the partitions that addRangePartitions applies if it is not for the first level of partitions. This level must be of a RANGE domain. It is an optional parameter with default value of 0.

The optional paramater locations is a string scalar/vector. If the paramater locations was specified when the database was created, we can use locations to specify where the new partitions located.


Append new values to the partition scheme of a database. This database must be of RANGE domain or of COMPO domain with at least one level of RANGE domain.


In the following example, we append (2017.08.12..2017.08.20) to the partition scheme of a database of COMPO domain.

$ n=1000000
$ ID=rand(100, n)
$ dates=2017.08.07..2017.08.11
$ date=rand(dates, n)
$ x=rand(10.0, n)
$ t=table(date, ID, x);
$ dbDate = database(, VALUE, 2017.08.07..2017.08.11)
$ dbID=database(, RANGE, 0 50 101);
$ db = database("dfs://compoDB", COMPO, [dbDate,dbID]);
$ pt = db.createPartitionedTable(t, `pt, `date`ID)
$ pt.append!(t);

$ addRangePartitions(db,101 150 200 250,1)

Please note that before appending data to the new partitions, we need to reload the table.

$ db=database("dfs://compoDB")
$ pt=loadTable(db,"pt")

$ t1=table(rand(101..249,n) as ID,rand(2017.08.07..2017.08.11,n) as date,rand(10.0,n) as x)
$ pt.append!(t1);

$ select count(*) from loadTable("dfs://compoDB","pt");

Please note that to add new partitions consecutively without appending new data, we need to reload the database before each addRangePartitions operation.

$ db=database("dfs://compoDB");
$ addRangePartitions(db, 250 300,1)

$ db=database("dfs://compoDB")
$ addRangePartitions(db, 300 350,1)

$ db=database("dfs://compoDB")
$ addRangePartitions(db, 350 400,1)