Source: https://dev-docs.yueshu.com.cn/v5.3.2/database-gql-reference/fe/expressions/constant/ Documentation version: v5.3.2 # 常量表达式 常量表达式返回一个常量字面量。常量字面量是可以在查询中直接使用的固定值,并且在操作过程中不会被改变。 ## 语法 语法图源码 constant_value_expression ```` constant_value_expression ::= literal ```` ## 参数 ### `literal` 常量字面量。`literal`支持多种数据类型的字面量,如下所示: - 数值字面量 - 布尔字面量 - 字符串字面量 - 日期和时间字面量 - 列表字面量 - 记录字面量 - 向量字面量 - 空值(`NULL`) 更多信息,请参见[数据类型](https://dev-docs.yueshu.com.cn/v5.3.2/database-gql-reference/data-types/)和[字面量](https://dev-docs.yueshu.com.cn/v5.3.2/database-gql-reference/fe/literals/)。 ## 示例 ```` ''' RETURN 1 AS num1, 3.4 AS num2, true AS bool1, "str literal" AS str1, DATE '2024-01-01' AS temporal1, DURATION ({years:1, months:2}) AS duration1, LIST [2,3,4] AS list1, {a:1, b:true, c:"str literal"} AS record1, VECTOR<3, FLOAT>([1.0, 2.0, 3.0]) AS v1, NULL AS null1 ''' ```` 返回: ```` +------+------+-------+-------------+------------+-----------+---------+------------------------------+---------------+-------+ | num1 | num2 | bool1 | str1 | temporal1 | duration1 | list1 | record1 | v1 | null1 | +------+------+-------+-------------+------------+-----------+---------+------------------------------+---------------+-------+ | 1 | 3.4 | true | str literal | 2024-01-01 | P1Y2M | [2,3,4] | {a:1,b:true,c:"str literal"} | [1.0,2.0,3.0] | null | +------+------+-------+-------------+------------+-----------+---------+------------------------------+---------------+-------+ ````