feat:SQL supports dot syntax to access fields

This commit is contained in:
rulego-team
2025-06-16 12:41:19 +08:00
parent 8d12c2860f
commit a05f4ace98
12 changed files with 1283 additions and 327 deletions

View File

@ -17,6 +17,7 @@ import (
"github.com/rulego/streamsql/functions"
"github.com/rulego/streamsql/logger"
"github.com/rulego/streamsql/types"
"github.com/rulego/streamsql/utils"
"github.com/rulego/streamsql/window"
)
@ -441,9 +442,20 @@ func (s *Stream) processDirectData(data interface{}) {
result[outputName] = nil
}
} else {
// 普通字段
if value, exists := dataMap[fieldName]; exists {
// 普通字段 - 支持嵌套字段
var value interface{}
var exists bool
if utils.IsNestedField(fieldName) {
value, exists = utils.GetNestedField(data, fieldName)
} else {
value, exists = dataMap[fieldName]
}
if exists {
result[outputName] = value
} else {
result[outputName] = nil
}
}
}