Add a Tablestore data source

更新时间:
复制 MD 格式

This document describes how to add a Tablestore data source in DataV and configure its parameters.

Prerequisites

You must have a Tablestore data source ready to add.

Important

You must add the IP addresses for the corresponding region to the whitelist of your data source. This ensures that DataV can access your database. For more information, see Configure a database whitelist.

Limits

This feature is available only in DataV Enterprise Edition and later versions.

Add a Tablestore data source

  1. Access the DataV console.

  2. On the Workbench page, click Data Preparation > Data Source in the navigation pane on the left. On the Data Source page, click New Data Source.

  3. From the Type drop-down list, select TableStore.

  4. Enter the Tablestore information.

    image

    Parameter

    Description

    Name

    The display name for the data source. You can enter any name.

    AK ID

    The AccessKey ID of the account that has access permissions for Tablestore.

    AK Secret

    The AccessKey secret of the account that has access permissions for Tablestore.

    Public Endpoint

    The service endpoint for Tablestore. Enter the endpoint for the Tablestore instance that you want to access.

  5. After entering the information, click OK to add the data source.

    The new data source is automatically added to the data source list.

Use a Tablestore data source

  1. Access the DataV console.

  2. On the Workbench page, hover over the data dashboard you want to edit and click Edit.

    Important

    If you haven't created a data dashboard on your Workbench page, please see Create a PC Dashboard Using a Template for guidance on creating one.

  3. On the canvas editing page, select a widget from the canvas.

    If your canvas lacks widgets, please add them first. For more information, see Widget Canvas Operations.

  4. In the widget configuration panel on the right, select Data Source.

    image

  5. In the Configure Data Source section, set Data Source Type to TableStore.

  6. From the Select Existing Data Source drop-down list, select the Tablestore data source that you configured.

  7. From the Select Operation drop-down list, select an operation.

    The following operations are supported:

    • getRow: This operation corresponds to the Tablestore GetRow API. For more information, see GetRow API reference.

    • getRange: This operation corresponds to the Tablestore GetRange API. For more information, see GetRange API reference.

    • SQL: SQL query.

  8. Enter a query statement in the Select Operation editor.

    • The query parameters must be in JSON object format.

    • 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"
          ]
      }

      Parameter

      Description

      table_name

      The name of the Tablestore table to query.

      rows

      The primary key of the row.

      Important

      If the table has multiple primary key columns, the number and data types of the columns you set must match those of the table.

      columns

      Enter the names of the columns to return.

    • If you select the getRange operation, you can read data within a specified primary key range. The parameters are in the following format:

      {
          "table_name": "test",
          "direction": "FORWARD",
          "columns": [
              "id",
              "test"
          ],
          "range": {
              "limit": 4,
              "start": {
                  "id": "InfMin"
              },
              "end": {
                  "id": "3"
              }
          }
      }

      Parameter

      Description

      table_name

      The name of the Tablestore table to query.

      direction

      The read direction.

      • If the value is `FORWARD`, the start primary key must be less than the end primary key. The returned rows are sorted by primary key in ascending order.

      • If the value is `BACKWARD`, the start primary key must be greater than the end primary key. The returned rows are sorted by primary key in descending order.

      For example, a table has two primary keys, A and B, where A is less than B. A forward read of `[A, B)` returns rows with primary keys greater than or equal to A and less than B. A backward read of `[B, A)` returns rows with primary keys greater than A and less than or equal to B.

      columns

      The set of columns to read. The columns can be primary key columns or attribute columns.

      If you do not specify which columns to return, the entire row is returned.

      If a row's primary key is in the read range but the row does not contain any of the specified columns, the row is not included in the result.

      limit

      The maximum number of rows to return. This value must be greater than 0.

      Tablestore stops the operation after it returns the specified maximum number of rows, even if more data exists in the specified range.

      start

      The start and end primary keys for the range read. The keys must be valid primary keys or virtual points composed of `InfMin` and `InfMax` types. The number of columns in a virtual point must be the same as the number of primary key columns.

      `InfMin` represents negative infinity. Any value is greater than `InfMin`. `InfMax` represents positive infinity. Any value is less than `InfMax`.

      Important

      If the table has multiple primary key columns, the number and data types of the columns you set must match those of the table.

      • `start` is the start primary key. The range is inclusive of the start key.

      • end specifies the end primary key. The corresponding row is excluded from the result, regardless of whether it exists.

      end

  9. Click View Data Response to view the results.

Example

  1. Prepare the Tablestore data.

    1. Log on to the TableStore console.

    2. In the Tablestore console, create an instance and a data table. For more information, see Create an instance and Create a data table.

      The following figure shows an instance named test. The instance contains three rows of data. Each row has two columns: id (primary key, integer) and test (string).Table Store数据

  2. Configure the data source.

    image

  3. Query parameters.

    • Query data using the getRow method.image.png

      The following figure shows the data response.image.png

    • Query data using the getRange method.image.png

      The following figure shows the data response.image.png

    Note

    When you use the getRange method, the filter condition sets start to id: InfMin and end to id: 3. The query returns two records with id values of 1 and 2. The getRange operation does not include the end row, so the row with an id of 3 is not returned.

What to do next

After you obtain the raw data, see Configure a widget data source to adapt the data for your widgets.

FAQ

For more information, see FAQ about data source configuration and usage.