linxt20 opened a new pull request, #11765: URL: https://github.com/apache/iotdb/pull/11765
This modification is based on the work in https://github.com/apache/iotdb/pull/11681. The main improvements of this work are: - Implemented new syntax for null checking in template filtering. - Supported distinguishing between the template name 'null' and the null value. - Fixed the scenario where using the string 'null' as a return result led to an empty null value. The expected outcomes of this implementation are as follows: ``` // Query to display activated template columns effect IoTDB > show devices // Execution result +-----------------+-------------+-------------+ | devices | isAligned | template | +-----------------+-------------+-------------+ |root.ln.wf01.wt01| false | t1 | |root.ll.wf02.wt02| false | null | +-----------------+-------------+-------------+ // Query to filter by template column equals condition IoTDB > show devices where template = 't1' // Execution result +-----------------+-------------+-------------+ | devices | isAligned | template | +-----------------+-------------+-------------+ |root.ln.wf01.wt01| false | t1 | +-----------------+-------------+-------------+ // Query to filter by template column equals null condition IoTDB > show devices where template is null // Execution result +-----------------+-------------+-------------+ | devices | isAligned | template | +-----------------+-------------+-------------+ |root.ll.wf02.wt02| false | null | +-----------------+-------------+-------------+ // Query to filter by template column not equals condition IoTDB > show devices where template != 't1' // Execution result +-----------------+-------------+-------------+ | devices | isAligned | template | +-----------------+-------------+-------------+ |root.ll.wf02.wt02| false | null | +-----------------+-------------+-------------+ // Query to filter by template column not equals null condition IoTDB > show devices where template is not null // Execution result +-----------------+-------------+-------------+ | devices | isAligned | template | +-----------------+-------------+-------------+ |root.ln.wf01.wt01| false | t1 | +-----------------+-------------+-------------+ ``` Implementation Details: - Implemented new syntax for null checking in template filtering: - G4 Grammar for Statement Generation: Added new syntax in G4 under deviceswhereclause for templateEqualExpression, enabling queries for null values using 'is null' and 'is not null'. - Implementation of TemplateFilter Logic: Based on G4 modifications, corresponding changes were made in ASTVisitor's visitshowdevice, distinguishing four cases for 'is null' and 'is not null'. The previously implemented createTemplateFilter function was called with a null templateName for subsequent evaluations. - Execution by Operator: In SchemaCountOperator, trygetnext uses schemaReader's getDeviceReader in schema creation. DeviceFilterVisitor handles TemplateFilter visits. The logic checks if the stored template name is not empty. If the filter's template name is not empty and doesn't match the stored template name, it's considered a match. Similarly, when the stored template name is empty and the filter's template name is also empty, it's considered a match. - Supported distinguishing between the template name 'null' and the null value: - G4 Grammar for Statement Generation: Modified G4 under deviceswhereclause for templateEqualExpression, changing the objects for 'template =' or 'template !=' from identifier to STRING_LITERAL. - Implementation of TemplateFilter Logic: Following the G4 changes, the parsing function for identifier in ASTVisitor's visitshowdevice needed modification to parse StringLiteral instead. - Fixed the scenario where using the string 'null' as a return result led to an empty null value: - Execution by Operator: In the final trygetnext function, setColumns was used to set the results obtained from schemaReader to the respective columns. For displaying null values, the previous method of writing into a static NULL string variable via writeBinary was replaced with appendNull()." -- 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]
