After creating a direct-connect dataset, to avoid scanning the entire partitioned table when querying data later, you need to filter data based on partition fields. This article introduces how to configure partition fields for direct-connect datasets that use partitioned tables to improve filtering efficiency during subsequent data queries.
A direct-connect dataset has been created, and the data table in the source data engine is a partitioned table.
After creating the corresponding direct-connect dataset, go to the dataset details page and click the "Edit" button in the upper right corner to enter the dataset editing page.
On the dataset editing page, click the "Field settings" button in the upper right corner to enter the field settings page, then modify partition fields of text or numeric type.
Parameters | Configuration description |
|---|---|
Data type | Only when the original field type is date or datetime can it be directly set as a partition field. If the original field is of text or numeric type (such as Int or String), you must first change its data type to "date", configure the correct format (see expression), and then set it as a partition field. |
Expression | Convert partition fields of text or numeric type to date type. The conversion syntax varies by engine. Below are examples for common engines (using
warning The converted format must match the actual value of the source field (such as |
Set partition | In the field configuration list, locate the "Operation" column for the corresponding field and click the "Set partition" button to set this field as the dataset partition field. |
tip
Scope of application: Only effective for direct single node connections (multi-node and custom SQL nodes do not support setting dataset partition fields).
Automatic setting logic: If the table's partition field is already of date type, the system will automatically set it as the dataset partition field; other types (text or numeric) will not be set automatically and require the user to manually complete the above three steps: "data type → expression → set partition".
Role of partition field: Once set successfully, a "Recent data in N days" filter will be automatically added on the visualization query side, styled as a date filter.
Supported types and formats (direct connection):
yyyyMMdd format or timestamp.yyyyMMdd, yyyy-MM-dd, and yyyy/MM/dd formats.(Optional) Modify the field name. Since the above operation converts the field type using a field expression, it is recommended that you modify the field name.
If you do not modify the field name, when saving the dataset, the interface will display a field name error. You can also choose not to modify the field name and select "Save anyway" here.
After completing the above configuration, when querying data in the corresponding dataset, you can easily filter data using the configured partition fields.
As shown in the figure above, on the visual query page, the configured partition fields are automatically added to the filter configuration results, and it supports convenient selection of the date range to filter using the date component.