linxt20 opened a new pull request, #11681:
URL: https://github.com/apache/iotdb/pull/11681
- **Function Overview:** Upon using `show devices`, this feature enables
viewing template information activated for each device, and allows querying a
list of devices based on a specified template name using `where` clause.
- **Detailed Functionality:**
- **Show devices Query for Template Usage:** Enhances the existing `show
devices` display (devices, isAligned) by adding a new column (`template`)
showcasing device usage of activated templates. For cases where a template is
not used or hasn't been activated, it will uniformly display `null`. For
devices with activated templates, the name of the activated template will be
displayed.
- **Filtering Devices Activated by a Specific Template using `where
template=xxx`:** The presentation format is similar to that of `show devices`,
based on the results of `show devices` (devices, isAligned, template). It
filters the activation template information column based on the specified
template name.
- **Expected Functionality:** // Statement Execution - Displaying the
activated template column effect
```
IoTDB > show devices
// Execution Result
+-----------------+-------------+-------------+
| devices | isAligned | template |
+-----------------+-------------+-------------+
| root.ln.wf01.wt01 | false | t1 |
| root.ll.wf02.wt02 | false | null |
+-----------------+-------------+-------------+
```
```
// Statement Execution - Filtering based on device column
IoTDB > show devices root.ln.**
// Execution Result
+-----------------+-------------+-------------+
| devices | isAligned | template |
+-----------------+-------------+-------------+
| root.ln.wf01.wt01 | false | t1 |
+-----------------+-------------+-------------+
```
```
// Statement Execution - Filtering based on template column with equality
condition
IoTDB > show devices where template = t1
// Execution Result
+-----------------+-------------+-------------+
| devices | isAligned | template |
+-----------------+-------------+-------------+
| root.ln.wf01.wt01 | false | t1 |
+-----------------+-------------+-------------+
```
```
// Statement Execution - Filtering based on template column with inequality
condition
IoTDB > show devices where template != t1
// Execution Result
+-----------------+-------------+-------------+
| devices | isAligned | template |
+-----------------+-------------+-------------+
| root.ll.wf02.wt02 | false | null |
+-----------------+-------------+-------------+
```
- **Implementing Feature Logic, Modifications Sequentially According to the
MPP Query Process**
- **G4 Grammar for Statement Generation**: Here, modifications are made
within the IoTDBSqlParser in the devicesWhereClause, adding
templateEqualExpression to support the syntax of filtering templates in the
'where' clause.
- **Implementation of TemplateFilter Logic:** Corresponding to the G4
grammar, enhancements are made within the visitshowdevice of ASTVisitor to
include parsing for templateEqualExpression content. This content is read as a
SchemaFilter. Currently, there is no specific SchemaFilter implementation for
templates. Hence, a TemplateFilter class is implemented in
iotdb-core/node-commons under schema/filter. Additionally, the
SchemaFilterFactory management class is updated with createTemplateIdFilter to
uniformly create TemplateFilter instances. The SchemaFilterType class now
includes TEMPLATE_FILTER type, and within the SchemaFilterVisitor class, the
default visit for visitTemplateFilter is included.
- **Parsing in QueryExecution:** In analyzeVisitor within visitshowdevice,
when retrieving header information, the header for template columns is added.
- **Execution by Operator:** In trygetnext, a schemaReader is first
constructed. Within the getDeviceReader function of schemaReader,
DeviceFilterVisitor is utilized for handling TemplateFilter access.
Implementation for template filtering judgment concerning devices needs to be
done within DeviceFilterVisitor. Once schemaReader construction is completed,
setColumns is invoked to set the results in the corresponding columns.
Modification is required in DeviceSchemaSource's transformToTsBlockColumns to
append the device's template activation information at the end. Retrieval of
template information from the device is necessary, thus, a new interface is
added to IDeviceSchemaInfo, which is implemented within ShowDevicesResult.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]