QueryAggregateExpression 查询聚合函数
1. 结构声明
- TS Declaration
- JSON Schema
class QueryAggregateExpression extends LogicItem {
asName?: string;
aggregateName: 'COUNT' | 'COUNTD' | 'SUM' | 'AVG' | 'MAX' | 'MIN';
aggregateParam: QueryFieldExpression;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"changedTime": {
"$ref": "#/definitions/long"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"folded": {
"type": "boolean"
},
"offsetX": {
"type": "number"
},
"offsetY": {
"type": "number"
},
"typeAnnotation": {
"$ref": "#/definitions/TypeAnnotation"
},
"breakpoint": {
"type": "string",
"enum": [
"ENABLED",
"DISABLED"
]
},
"asName": {
"type": "string"
},
"aggregateName": {
"type": "string",
"enum": [
"COUNT",
"COUNTD",
"SUM",
"AVG",
"MAX",
"MIN"
]
},
"aggregateParam": {
"$ref": "#/definitions/QueryFieldExpression"
}
},
"required": [
"aggregateName",
"aggregateParam"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "QueryAggregateExpression",
"aggregateName": "SUM",
"aggregateParam": {
"concept": "QueryFieldExpression",
"isDotStar": false,
"entityAsName": "OrderProduct",
"propertyName": "amount",
"asName": ""
},
"asName": "totalAmount"
}
concept: QueryAggregateExpression
aggregateName: SUM
aggregateParam:
concept: QueryFieldExpression
isDotStar: false
entityAsName: OrderProduct
propertyName: amount
asName: ""
asName: totalAmount
对应的代码如下:
- 文本化 NASL
- Natural TS
totalAmount: SUM(OrderProduct.amount)
totalAmount: SUM(OrderProduct.amount)