Creating JSON Tables

This topic describes how to create MapR Database JSON tables using either programmatic APIs or dbshell.

Note: Before creating a table, you typically create a directory and MapR volume. This is not required; however, it is a good practice. For example, assuming both the directory and volume names are sample, the command would be:
// Create directories with hadoop
hadoop fs -mkdir /sample

// Create a MapR volume using maprcli create volume
maprcli volume create -name sample -path /sample -type rw

The following Java code examples show you how to create a table in the following ways:

  • By using the default values for the table attributes,
  • By setting specific values for the table attributes.

See the Admin and TableDescriptor APIs for more information.

The following example shows how to create a table by calling an Admin object's createTable() method and passing, as an argument, the path that you want to use for the new table:

public void createJSONTable(String tablePath) throws DBException {
    try (Admin admin = MapRDB.newAdmin()) {
        if (!admin.tableExists(tablePath)) {

Tables created with this version of the createTable() method use the default values for their attributes.

Alternatively, the following example how to create a table by passing a TableDescriptor object as an argument to the createTable() method:

/* Create a TableDescriptor for the table to create,
 * passing in the path of the table. 
TableDescriptor tableDescriptor = MapRDB.newTableDescriptor(tablePath);
/* Pass the TableDescriptor object and the path to the table
 * to the Admin.createTable() method. 
public void createJSONTable(String tablePath, TableDescriptor tableDescriptor) throws DBException {
    try (Admin admin = MapRDB.newAdmin()) {
        if (!admin.tableExists(tablePath)) {

This alternative allows you to set values for some of the table's attributes.

To create a table in the Node.js OJAI client, call the Connection.createStore() method:

    .then((store) => {
        // Process result

The method returns a DocumentStore object.

To create a table in the Python OJAI client, call the Connection.create_store() method:

store = connection.create_store(store_path=table_path)

The method returns a DocumentStore object.

The following dbshell command shows code syntax for creating a table:

# mapr dbshell
maprdb root:> create /<tablePath>/<tableName>    

To create a table in the C# OJAI client, call the connection.CreateStore(string storePath) method:

var store = connection.CreateStore(string storePath);

The method returns a DocumentStore object.

To create a table in the Go OJAI client, call the connection.CreateStore() function:

store, error := connection.CreateStore("/store_path")

The function returns a new DocumentStore and an error.