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
- Log on to the DataV console.
- Click the Data Sources tab and then Add Data Source.
- Select TableStore from the Type drop-down list.
- Enter information about the Tablestore data source.
Parameter Description Name The name of the data source you want to add. You can set this parameter to a custom name. AK ID The AccessKey ID of the account that has the permissions to access the Tablestore data source. AK Secret The AccessKey secret of the account that has the permissions to access the Tablestore data source. Internet The endpoint of the Tablestore data source that you want to add. For more information, see Endpoints. - 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
- Log on to the DataV console.
- 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.
- 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.
- In the right-side configuration panel, click the Data tab and then Set.
- In the Configure Data Source panel, select TableStore from the Data Source Type drop-down list.
- In the Select Data Source section, select the configured Tablestore data source.
- In the Select Action section, select the operation that you want to perform.
- 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" ] }
Part Feature table_name The name of the Tablestore table that you want to query. rows The 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.columns The 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" } } }
Part Feature table_name The name of the Tablestore table that you want to query. direction The 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.
columns The 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.
limit The 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.
start The 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
- Click Preview Data Response to view the returned data.
Sample request
- Prepare Tablestore data.
- Configure the data sources.
- The query parameter.
- Query data by using
getRow
.The following results are returned. - Query data by using
getRange
.The following results are returned.
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. - Query data by using