This topic describes how to add a Tablestore data source in DataV. It also describes related parameters.

Prerequisites

The Tablestore data source that you want to add exists.

Add a Tablestore data source

  1. Log on to the DataV console.
  2. Click the Data Sources tab and then Add Data Source.
  3. Select TableStore from the Type drop-down list.
  4. Enter information about the Tablestore data source.
    Add Data Source
    ParameterDescription
    NameThe name of the data source you want to add. You can set this parameter to a custom name.
    AK IDThe AccessKey ID of the account that has the permissions to access the Tablestore data source.
    AK SecretThe AccessKey secret of the account that has the permissions to access the Tablestore data source.
    InternetThe endpoint of the Tablestore data source that you want to add. For more information, see Endpoints.
  5. After you enter the information about the Tablestore data source, click OK.

    The added data source is displayed in the data source list.

Use a Tablestore data source

  1. Log on to the DataV console.
  2. On the Projects tab, move the pointer over the project that you want to edit and click Edit.
    Important If you have not created a visualization application on the My Visualizations page, see Use a template to create a PC-side visual application to create a visualization application.
  3. In Canvas Editor, click a widget on the canvas.

    If no widget is added to the canvas, add a widget first. For more information, see Add a domain name.

  4. In the right-side configuration panel, click the Data tab and then Set.
    Configure data sources
  5. In the Configure Data Source panel, select TableStore from the Data Source Type drop-down list.
  6. In the Select Data Source section, select the configured Tablestore data source.
  7. In the Select Action section, select the operation that you want to perform.
    The system supports the following operations:
    • getRow: indicates the GetRow operation of Tablestore. For more information, see GetRow.
    • getRange: indicates the GetRange operation of Tablestore. For more information, see GetRange.
  8. In the code editor of the Select Action section, enter query statements.
    • Query parameters must be JSON objects.
    • If you select the getRow operation, a single row of data is read based on the specified primary key.

      The parameters are in the following format:

      {
          "table_name": "test",
          "rows": {
              "id": "1"
          },
          "columns": [
              "id",
              "test"
          ]
      }
      PartFeature
      table_nameThe name of the Tablestore table that you want to query.
      rowsThe primary key of the row.
      Important The number and data types of primary key columns specified for each row must be the same as those of primary key columns in the table.
      columnsThe names of the columns that you want to return.
    • If you select the getRange operation, a single row of data is read based on the specified primary key. The parameters are in the following format:
      {
          "table_name": "test",
          "direction": "FORWARD",
          "columns": [
              "id",
              "test"
          ],
          "range": {
              "limit": 4,
              "start": {
                  "id": "InfMin"
              },
              "end": {
                  "id": "3"
              }
          }
      }
      PartFeature
      table_nameThe name of the Tablestore table that you want to query.
      directionThe direction for reading.
      • If you set this parameter to FORWARD, the value of the inclusive_start_primary_key parameter must be smaller than the value of the exclusive_end_primary_key parameter, and the rows in the response are sorted in the ascending order of primary key values.
      • If you set this parameter to BACKWARD, the value of the inclusive_start_primary_key parameter must be greater than the value of the exclusive_end_primary_key parameter, and the rows in the response are sorted in descending order of primary key values.

      For example, if you set the direction parameter to FORWARD for a table that contains two primary keys A and B, and the value of A is smaller than the value of B, the rows whose primary key values are greater than or equal to the value of A but smaller than the value of B are returned in ascending order from A to B. If you set the direction parameter to BACKWARD, the rows whose primary key values are smaller than or equal to the value of B and greater than the value of A are returned in descending order from B to A.

      columnsThe columns that you want to return. You can specify the names of primary key columns or attribute columns.

      If you do not specify a column name, all data in the row is returned.

      If a row is in the specified range that you want to read based on the primary key value but does not contain the specified columns that you want to return, the response excludes the row.

      limitThe maximum number of rows to return. The value of this parameter must be greater than 0.

      An operation stops after the maximum number of rows that can be returned in the forward or backward direction is reached, even if some rows in the specified range are not returned.

      startThe start and end primary keys of the range to read. The start and end primary keys must be valid primary keys or virtual points that consist of the InfMin and InfMax type data. The number of columns for each virtual point must be the same as that of each primary key.

      InfMin indicates an infinitely small value. All values of other types are greater than InfMin. InfMax indicates an infinitely great value. All values of other types are less than InfMax.

      Important The number and data types of primary key columns specified for each row must be the same as those of primary key columns in the table.
      • start indicates the start primary key. If the row that contains the start primary key exists, the row of data is returned.
      • end indicates the end primary key. No matter whether the row that contains the end primary key exists, the row of data is not returned.
      end
  9. Click Preview Data Response to view the returned data.

Sample request

  1. Prepare Tablestore data.
    1. Log on to the Tablestore console.
    2. Create instances and tables in the Tablestore console. For more information, see Create instances and Create tables.
      The test instance is created. A table is created for this instance and contains three rows of data and two columns: id(Primary Key) and test. The id(Primary Key) column is of the INTEGER type. The test column is of the STRING type. The following figure shows the table details. Tablestore data
  2. Configure the data sources.
    Configure data sources
  3. The query parameter.
    • Query data by using getRow. Query data by using getRow
      The following results are returned. Query results
    • Query data by using getRange. Query data by using getRange
      The following results are returned. Query results
    Note If you query data by using getRange, start is id: InfMin, and end is id: 3. Therefore, data of the row with id of 1 and the row with id of 2 is obtained. This is because getRange neither contains the end row nor the row with id of 3.