例如我流中的内容是
{"a": 1, "b": 2}
我想获取整个对象,而不是单个字段的值的话应该如何传递呢
function 支持 * 的可以直接用。否则可以试试看 streamName.*
我直接使用*的话会报以下错误,怎么查看stream的name呢
| time="2024-10-25T08:47:15Z" level=info msg="sink result for rule 111: [{\"error\":\"unexpected wildcard value \\u003cnil\\u003e\"}]" file="sink/log_sink.go:32" rule=111
function调用如下
"223a22cc-bef2-4045-b2c8-f707135f637e": {
"type": "operator",
"nodeType": "function",
"props": {
"expr": "test(*,\"abc\",\"cde\")"
}
}
eKuiper版本为1.13.4
stream就是source节点的名字
两种方式都尝试过了均无法获取到
这个有可复现的图规则吗?
数据源方面随意换一个可用的数据源均可,主要是test function那边每次在接收到数据后均会报错
ekuiper | time="2024-10-29T06:48:14Z" level=error msg="Operation 223a22cc-bef2-4045-b2c8-f707135f637e error: unexpected wildcard value <nil>" file="node/operations.go:121" rule=111
ekuiper | time="2024-10-29T06:48:14Z" level=info msg="sink result for rule 111: [{\"error\":\"unexpected wildcard value \\u003cnil\\u003e\"}]" file="sink/log_sink.go:32" rule=111
ekuiper | time="2024-10-29T06:48:14Z" level=error msg="Operation 223a22cc-bef2-4045-b2c8-f707135f637e error: unexpected wildcard value <nil>" file="node/operations.go:121" rule=111
ekuiper | time="2024-10-29T06:48:14Z" level=info msg="sink result for rule 111: [{\"error\":\"unexpected wildcard value \\u003cnil\\u003e\"}]" file="sink/log_sink.go:32" rule=111
testFunction.go
package main
import (
"fmt"
"github.com/lf-edge/ekuiper/pkg/api"
)
type test struct{}
func (t *test) Validate(args []interface{}) error {
if len(args) < 3 {
return fmt.Errorf("test function requires at least 3 arguments but got %d", len(args))
}
return nil
}
func (t *test) IsAggregate() bool {
return false
}
func (t *test) Exec(args []interface{}, ctx api.FunctionContext) (interface{}, bool) {
for _, arg := range args {
if arg == nil {
return nil, false
}
}
logger := ctx.GetLogger()
logger.Info(fmt.Sprintf(`test params: %v`, args))
return args[0], true
}
var Test test
TestGraphRule.json
{
"id": "111",
"name": "111",
"graph": {
"nodes": {
"ef65a6a5-d74b-4490-8894-5304e4dbf52f": {
"type": "source",
"nodeType": "testSource",
"props": {
"datasource": "topic.5ebe8841-8ab4-11ef-a086-0242ac120032.>",
"shared": true
}
},
"89b27d25-fd0b-4876-9758-35c01e66aacb": {
"type": "operator",
"nodeType": "pick",
"props": {
"fields": [
"data_object",
"ts"
]
}
},
"223a22cc-bef2-4045-b2c8-f707135f637e": {
"type": "operator",
"nodeType": "function",
"props": {
"expr": "test(*,\"str1\",\"str2\") as result"
}
},
"c03e1745-ccdb-4b9a-8f45-4fd214751f37": {
"type": "sink",
"nodeType": "log"
}
},
"topo": {
"sources": [
"ef65a6a5-d74b-4490-8894-5304e4dbf52f"
],
"edges": {
"ef65a6a5-d74b-4490-8894-5304e4dbf52f": [
"89b27d25-fd0b-4876-9758-35c01e66aacb"
],
"89b27d25-fd0b-4876-9758-35c01e66aacb": [
"223a22cc-bef2-4045-b2c8-f707135f637e"
],
"223a22cc-bef2-4045-b2c8-f707135f637e": [
"c03e1745-ccdb-4b9a-8f45-4fd214751f37"
]
}
}
}
}