@elastic/esql-types
ESQQL和PromQL ASTs的共享类型脚本类型定义. 纯粹的类型定义——没有运行时代码,没有依赖性.
安装
npm install @elastic/esql-types
使用量
import type {
// Top-level AST
ESQLAstQueryExpression,
ESQLAst,
// Commands
ESQLCommand,
ESQLAstHeaderCommand,
// Expressions
ESQLFunction,
ESQLFunctionCallExpression,
ESQLBinaryExpression,
ESQLColumn,
ESQLLiteral,
ESQLSource,
ESQLInlineCast,
ESQLOrderExpression,
// ... and more
} from '@elastic/esql-types';
PromQL 类型
import type {
PromQLAstQueryExpression,
PromQLAstExpression,
PromQLFunction,
PromQLSelector,
PromQLBinaryExpression,
PromQLLabel,
} from '@elastic/esql-types';
关键类型关系
ESQLAstQueryExpression root node — holds commands[]
ESQLCommand a pipeline stage (FROM, WHERE, STATS, …)
ESQLCommandOption named sub-clause (e.g. BY in STATS … BY)
ESQLAstExpression any expression in a command argument
ESQLFunction function call, binary op, unary op
ESQLColumn column reference (@timestamp, user.name)
ESQLLiteral scalar literal (number, string, boolean, null)
ESQLSource index source reference (logs-*, cluster:index)
ESQLList list literal ([1, 2, 3])
ESQLInlineCast inline cast (expr::type)
ESQLParamLiteral parameter placeholder (?, ?name, ?1)
ESQLAstHeaderCommand pre-query instructions (SET key = value; LET name = (subquery);)
页:1
ESQLAst实值ESQLAstCommand[],查询的历史矩阵形式。 偏爱ESQLAstQueryExpression(将命令列表包成一个合适的AST节点)用于新代码.ESQLFunction覆盖函数调用, 二进制表达式( e)a + b, (中文(简体) ),a == b),和无词表达式(-x, (中文(简体) ),NOT x) (中文(简体) ). 紧紧地与subtype字段 :'variadic-call', (中文(简体) ),'binary-expression', (中文(简体) ),'unary-expression', (中文(简体) ),'postfix-unary-expression'。 。 。 .- 地点信息( E)
ESQLLocation与min编号 :max在解析时设置,在构建节点时设置为零Builder。 。 。 .