SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
refactor: consolidate body column for JSON logs (#10325)
Piyush Singariya0e5a1283259c
diff --git a/go.mod b/go.modindex 60d01b7ac5..6718151288 100644--- a/go.mod+++ b/go.mod@@ -11,7 +11,6 @@ require (github.com/SigNoz/signoz-otel-collector v0.144.2github.com/antlr4-go/antlr/v4 v4.13.1github.com/antonmedv/expr v1.15.3- github.com/bytedance/sonic v1.14.1github.com/cespare/xxhash/v2 v2.3.0github.com/coreos/go-oidc/v3 v3.17.0github.com/dgraph-io/ristretto/v2 v2.3.0@@ -106,6 +105,7 @@ require (github.com/aws/aws-sdk-go-v2/service/sts v1.41.6 // indirectgithub.com/aws/smithy-go v1.24.0 // indirectgithub.com/bytedance/gopkg v0.1.3 // indirect+ github.com/bytedance/sonic v1.14.1 // indirectgithub.com/bytedance/sonic/loader v0.3.0 // indirectgithub.com/cloudwego/base64x v0.1.6 // indirectgithub.com/gabriel-vasile/mimetype v1.4.8 // indirectdiff --git a/pkg/modules/promote/implpromote/module.go b/pkg/modules/promote/implpromote/module.goindex a5ff24d0f5..c05e6eb875 100644--- a/pkg/modules/promote/implpromote/module.go+++ b/pkg/modules/promote/implpromote/module.go@@ -78,7 +78,7 @@ func (m *module) ListPromotedAndIndexedPaths(ctx context.Context) ([]promotetype// add the paths that are not promoted but have indexesfor path, indexes := range aggr {- path := strings.TrimPrefix(path, telemetrylogs.BodyJSONColumnPrefix)+ path := strings.TrimPrefix(path, telemetrylogs.BodyV2ColumnPrefix)path = telemetrytypes.BodyJSONStringSearchPrefix + pathresponse = append(response, promotetypes.PromotePath{Path: path,@@ -163,7 +163,7 @@ func (m *module) PromoteAndIndexPaths(}}if len(it.Indexes) > 0 {- parentColumn := telemetrylogs.LogsV2BodyJSONColumn+ parentColumn := telemetrylogs.LogsV2BodyV2Column// if the path is already promoted or is being promoted, add it to the promoted columnif _, promoted := existingPromotedPaths[it.Path]; promoted || it.Promote {parentColumn = telemetrylogs.LogsV2BodyPromotedColumndiff --git a/pkg/querier/builder_query.go b/pkg/querier/builder_query.goindex 8ec2fab7bb..d3a382a343 100644--- a/pkg/querier/builder_query.go+++ b/pkg/querier/builder_query.go@@ -10,13 +10,11 @@ import ("github.com/ClickHouse/clickhouse-go/v2""github.com/SigNoz/signoz/pkg/errors"- "github.com/SigNoz/signoz/pkg/telemetrylogs""github.com/SigNoz/signoz/pkg/telemetrystore""github.com/SigNoz/signoz/pkg/types/ctxtypes""github.com/SigNoz/signoz/pkg/types/instrumentationtypes"qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5""github.com/SigNoz/signoz/pkg/types/telemetrytypes"- "github.com/bytedance/sonic")type builderQuery[T any] struct {@@ -262,40 +260,6 @@ func (q *builderQuery[T]) executeWithContext(ctx context.Context, query string,return nil, err}- // merge body_json and promoted into body- if q.spec.Signal == telemetrytypes.SignalLogs {- switch typedPayload := payload.(type) {- case *qbtypes.RawData:- for _, rr := range typedPayload.Rows {- seeder := func() error {- body, ok := rr.Data[telemetrylogs.LogsV2BodyJSONColumn].(map[string]any)- if !ok {- return nil- }- promoted, ok := rr.Data[telemetrylogs.LogsV2BodyPromotedColumn].(map[string]any)- if !ok {- return nil- }- seed(promoted, body)- str, err := sonic.MarshalString(body)- if err != nil {- return errors.Wrapf(err, errors.TypeInternal, errors.CodeInternal, "failed to marshal body")- }- rr.Data["body"] = str- return nil- }- err := seeder()- if err != nil {- return nil, err- }-- delete(rr.Data, telemetrylogs.LogsV2BodyJSONColumn)- delete(rr.Data, telemetrylogs.LogsV2BodyPromotedColumn)- }- payload = typedPayload- }- }-return &qbtypes.Result{Type: q.kind,Value: payload,@@ -423,18 +387,3 @@ func decodeCursor(cur string) (int64, error) {}return strconv.ParseInt(string(b), 10, 64)}--func seed(promoted map[string]any, body map[string]any) {- for key, fromValue := range promoted {- if toValue, ok := body[key]; !ok {- body[key] = fromValue- } else {- if fromValue, ok := fromValue.(map[string]any); ok {- if toValue, ok := toValue.(map[string]any); ok {- seed(fromValue, toValue)- body[key] = toValue- }- }- }- }-}diff --git a/pkg/querier/consume.go b/pkg/querier/consume.goindex 58c3df871c..72ce085657 100644--- a/pkg/querier/consume.go+++ b/pkg/querier/consume.go@@ -14,7 +14,6 @@ import ("github.com/ClickHouse/clickhouse-go/v2/lib/driver"qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5""github.com/SigNoz/signoz/pkg/types/telemetrytypes"- "github.com/bytedance/sonic")var (@@ -394,17 +393,11 @@ func readAsRaw(rows driver.Rows, queryName string) (*qbtypes.RawData, error) {// de-reference the typed pointer to anyval := reflect.ValueOf(cellPtr).Elem().Interface()-- // Post-process JSON columns: normalize into structured values+ // Post-process JSON columns: normalize into String valueif strings.HasPrefix(strings.ToUpper(colTypes[i].DatabaseTypeName()), "JSON") {switch x := val.(type) {case []byte:- if len(x) > 0 {- var v any- if err := sonic.Unmarshal(x, &v); err == nil {- val = v- }- }+ val = string(x)default:// already a structured type (map[string]any, []any, etc.)}diff --git a/pkg/querybuilder/fallback_expr.go b/pkg/querybuilder/fallback_expr.goindex dbc2bba995..961f93f99f 100644--- a/pkg/querybuilder/fallback_expr.go+++ b/pkg/querybuilder/fallback_expr.go@@ -219,7 +219,6 @@ func DataTypeCollisionHandledFieldName(key *telemetrytypes.TelemetryFieldKey, va// we don't have a toBoolOrNull in ClickHouse, so we need to convert the bool to a stringvalue = fmt.Sprintf("%t", v)}-case telemetrytypes.FieldDataTypeInt64,telemetrytypes.FieldDataTypeArrayInt64,telemetrytypes.FieldDataTypeNumber,diff --git a/pkg/querybuilder/where_clause_visitor.go b/pkg/querybuilder/where_clause_visitor.goindex 35a1bb1afb..855f3b37df 100644--- a/pkg/querybuilder/where_clause_visitor.go+++ b/pkg/querybuilder/where_clause_visitor.go@@ -313,37 +313,30 @@ func (v *filterExpressionVisitor) VisitPrimary(ctx *grammar.PrimaryContext) anyreturn ""}child := ctx.GetChild(0)+ var searchText stringif keyCtx, ok := child.(*grammar.KeyContext); ok {// create a full text search condition on the body field-- keyText := keyCtx.GetText()- cond, err := v.conditionBuilder.ConditionFor(context.Background(), v.fullTextColumn, qbtypes.FilterOperatorRegexp, FormatFullTextSearch(keyText), v.builder, v.startNs, v.endNs)- if err != nil {- v.errors = append(v.errors, fmt.Sprintf("failed to build full text search condition: %s", err.Error()))- return ""- }- return cond+ searchText = keyCtx.GetText()} else if valCtx, ok := child.(*grammar.ValueContext); ok {- var text stringif valCtx.QUOTED_TEXT() != nil {- text = trimQuotes(valCtx.QUOTED_TEXT().GetText())+ searchText = trimQuotes(valCtx.QUOTED_TEXT().GetText())} else if valCtx.NUMBER() != nil {- text = valCtx.NUMBER().GetText()+ searchText = valCtx.NUMBER().GetText()} else if valCtx.BOOL() != nil {- text = valCtx.BOOL().GetText()+ searchText = valCtx.BOOL().GetText()} else if valCtx.KEY() != nil {- text = valCtx.KEY().GetText()+ searchText = valCtx.KEY().GetText()} else {v.errors = append(v.errors, fmt.Sprintf("unsupported value type: %s", valCtx.GetText()))return ""}- cond, err := v.conditionBuilder.ConditionFor(context.Background(), v.fullTextColumn, qbtypes.FilterOperatorRegexp, FormatFullTextSearch(text), v.builder, v.startNs, v.endNs)- if err != nil {- v.errors = append(v.errors, fmt.Sprintf("failed to build full text search condition: %s", err.Error()))- return ""- }- return cond}+ cond, err := v.conditionBuilder.ConditionFor(context.Background(), v.fullTextColumn, qbtypes.FilterOperatorRegexp, FormatFullTextSearch(searchText), v.builder, v.startNs, v.endNs)+ if err != nil {+ v.errors = append(v.errors, fmt.Sprintf("failed to build full text search condition: %s", err.Error()))+ return ""+ }+ return cond}return "" // Should not happen with valid input@@ -383,6 +376,7 @@ func (v *filterExpressionVisitor) VisitComparison(ctx *grammar.ComparisonContextfor _, key := range keys {condition, err := v.conditionBuilder.ConditionFor(context.Background(), key, op, nil, v.builder, v.startNs, v.endNs)if err != nil {+ v.errors = append(v.errors, fmt.Sprintf("failed to build condition: %s", err.Error()))return ""}conds = append(conds, condition)@@ -648,7 +642,6 @@ func (v *filterExpressionVisitor) VisitValueList(ctx *grammar.ValueListContext)// VisitFullText handles standalone quoted strings for full-text searchfunc (v *filterExpressionVisitor) VisitFullText(ctx *grammar.FullTextContext) any {-if v.skipFullTextFilter {return ""}@@ -670,6 +663,7 @@ func (v *filterExpressionVisitor) VisitFullText(ctx *grammar.FullTextContext) anv.errors = append(v.errors, fmt.Sprintf("failed to build full text search condition: %s", err.Error()))return ""}+return cond}diff --git a/pkg/telemetrylogs/condition_builder.go b/pkg/telemetrylogs/condition_builder.goindex bc1de01797..39db3484e1 100644--- a/pkg/telemetrylogs/condition_builder.go+++ b/pkg/telemetrylogs/condition_builder.go@@ -3,14 +3,12 @@ package telemetrylogsimport ("context""fmt"- "slices"schema "github.com/SigNoz/signoz-otel-collector/cmd/signozschemamigrator/schema_migrator""github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/querybuilder"qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5""github.com/SigNoz/signoz/pkg/types/telemetrytypes"- "golang.org/x/exp/maps""github.com/huandu/go-sqlbuilder")@@ -35,7 +33,7 @@ func (c *conditionBuilder) conditionFor(return "", err}- if column.Type.GetType() == schema.ColumnTypeEnumJSON && querybuilder.BodyJSONQueryEnabled {+ if column.Type.GetType() == schema.ColumnTypeEnumJSON && querybuilder.BodyJSONQueryEnabled && key.Name != messageSubField {valueType, value := InferDataType(value, operator, key)cond, err := NewJSONConditionBuilder(key, valueType).buildJSONCondition(operator, value, sb)if err != nil {@@ -54,14 +52,14 @@ func (c *conditionBuilder) conditionFor(}// Check if this is a body JSON search - either by FieldContext- if key.FieldContext == telemetrytypes.FieldContextBody {+ if key.FieldContext == telemetrytypes.FieldContextBody && !querybuilder.BodyJSONQueryEnabled {tblFieldName, value = GetBodyJSONKey(ctx, key, operator, value)}tblFieldName, value = querybuilder.DataTypeCollisionHandledFieldName(key, value, tblFieldName, operator)// make use of case insensitive index for body- if tblFieldName == "body" {+ if tblFieldName == "body" || tblFieldName == messageSubColumn {switch operator {case qbtypes.FilterOperatorLike:return sb.ILike(tblFieldName, value), nil@@ -108,7 +106,6 @@ func (c *conditionBuilder) conditionFor(return sb.ILike(tblFieldName, fmt.Sprintf("%%%s%%", value)), nilcase qbtypes.FilterOperatorNotContains:return sb.NotILike(tblFieldName, fmt.Sprintf("%%%s%%", value)), nil-case qbtypes.FilterOperatorRegexp:// Note: Escape $$ to $$$$ to avoid sqlbuilder interpreting materialized $ signs// Only needed because we are using sprintf instead of sb.Match (not implemented in sqlbuilder)@@ -178,9 +175,8 @@ func (c *conditionBuilder) conditionFor(case schema.ColumnTypeEnumJSON:if operator == qbtypes.FilterOperatorExists {return sb.IsNotNull(tblFieldName), nil- } else {- return sb.IsNull(tblFieldName), nil}+ return sb.IsNull(tblFieldName), nilcase schema.ColumnTypeEnumLowCardinality:switch elementType := column.Type.(schema.LowCardinalityColumnType).ElementType; elementType.GetType() {case schema.ColumnTypeEnumString:@@ -247,19 +243,30 @@ func (c *conditionBuilder) ConditionFor(return "", err}- if !(key.FieldContext == telemetrytypes.FieldContextBody && querybuilder.BodyJSONQueryEnabled) && operator.AddDefaultExistsFilter() {- // skip adding exists filter for intrinsic fields- // with an exception for body json search- field, _ := c.fm.FieldFor(ctx, key)- if slices.Contains(maps.Keys(IntrinsicFields), field) && key.FieldContext != telemetrytypes.FieldContextBody {+ // Skip adding exists filter for intrinsic fields i.e. Table level log context fields+ buildExistCondition := operator.AddDefaultExistsFilter()+ switch key.FieldContext {+ case telemetrytypes.FieldContextLog, telemetrytypes.FieldContextScope:+ // pass; No need to build exist condition for top level columns+ // immediately return+ return condition, nil+ case telemetrytypes.FieldContextResource, telemetrytypes.FieldContextAttribute:+ // build exist condition for resource and attribute fields based on filter operator+ case telemetrytypes.FieldContextBody:+ // Querying JSON fields already account for Nullability of fields+ // so additional exists checks are not needed+ if querybuilder.BodyJSONQueryEnabled {return condition, nil}+ }+ if buildExistCondition {existsCondition, err := c.conditionFor(ctx, key, qbtypes.FilterOperatorExists, nil, sb)if err != nil {return "", err}return sb.And(condition, existsCondition), nil}+return condition, nil}diff --git a/pkg/telemetrylogs/condition_builder_test.go b/pkg/telemetrylogs/condition_builder_test.goindex 739b21fb31..269c86c017 100644--- a/pkg/telemetrylogs/condition_builder_test.go+++ b/pkg/telemetrylogs/condition_builder_test.go@@ -127,7 +127,8 @@ func TestConditionFor(t *testing.T) {{name: "Contains operator - body",key: telemetrytypes.TelemetryFieldKey{- Name: "body",+ Name: "body",+ FieldContext: telemetrytypes.FieldContextLog,},operator: qbtypes.FilterOperatorContains,value: 521509198310,diff --git a/pkg/telemetrylogs/const.go b/pkg/telemetrylogs/const.goindex e05cd548f4..89b36cc016 100644--- a/pkg/telemetrylogs/const.go+++ b/pkg/telemetrylogs/const.go@@ -1,7 +1,10 @@package telemetrylogsimport (+ "fmt"+"github.com/SigNoz/signoz-otel-collector/constants"+ "github.com/SigNoz/signoz/pkg/querybuilder"qbtypes "github.com/SigNoz/signoz/pkg/types/querybuildertypes/querybuildertypesv5""github.com/SigNoz/signoz/pkg/types/telemetrytypes")@@ -17,7 +20,7 @@ const (LogsV2TimestampColumn = "timestamp"LogsV2ObservedTimestampColumn = "observed_timestamp"LogsV2BodyColumn = "body"- LogsV2BodyJSONColumn = constants.BodyV2Column+ LogsV2BodyV2Column = constants.BodyV2ColumnLogsV2BodyPromotedColumn = constants.BodyPromotedColumnLogsV2TraceIDColumn = "trace_id"LogsV2SpanIDColumn = "span_id"@@ -34,8 +37,14 @@ const (LogsV2ResourcesStringColumn = "resources_string"LogsV2ScopeStringColumn = "scope_string"- BodyJSONColumnPrefix = constants.BodyV2ColumnPrefix+ BodyV2ColumnPrefix = constants.BodyV2ColumnPrefixBodyPromotedColumnPrefix = constants.BodyPromotedColumnPrefix++ // messageSubColumn is the ClickHouse sub-column that body searches map to+ // when BodyJSONQueryEnabled is true.+ messageSubField = "message"+ messageSubColumn = "body_v2.message"+ bodySearchDefaultWarning = "body searches default to `body.message:string`. Use `body.<key>` to search a different field inside body")var (@@ -118,3 +127,11 @@ var (},})++func bodyAliasExpression() string {+ if !querybuilder.BodyJSONQueryEnabled {+ return LogsV2BodyColumn+ }++ return fmt.Sprintf("%s as body", LogsV2BodyV2Column)+}diff --git a/pkg/telemetrylogs/field_mapper.go b/pkg/telemetrylogs/field_mapper.goindex dbea2e5bfa..5d4e7f0d5a 100644--- a/pkg/telemetrylogs/field_mapper.go+++ b/pkg/telemetrylogs/field_mapper.go@@ -30,7 +30,8 @@ var ("severity_text": {Name: "severity_text", Type: schema.LowCardinalityColumnType{ElementType: schema.ColumnTypeString}},"severity_number": {Name: "severity_number", Type: schema.ColumnTypeUInt8},"body": {Name: "body", Type: schema.ColumnTypeString},- LogsV2BodyJSONColumn: {Name: LogsV2BodyJSONColumn, Type: schema.JSONColumnType{+ messageSubColumn: {Name: messageSubColumn, Type: schema.ColumnTypeString},+ LogsV2BodyV2Column: {Name: LogsV2BodyV2Column, Type: schema.JSONColumnType{MaxDynamicTypes: utils.ToPointer(uint(32)),MaxDynamicPaths: utils.ToPointer(uint(0)),}},@@ -88,21 +89,26 @@ func (m *fieldMapper) getColumn(_ context.Context, key *telemetrytypes.Telemetryreturn logsV2Columns["attributes_bool"], nil}case telemetrytypes.FieldContextBody:- // Body context is for JSON body fields- // Use body_json if feature flag is enabled+ // Body context is for JSON body fields. Use body_v2 if feature flag is enabled.if querybuilder.BodyJSONQueryEnabled {- return logsV2Columns[LogsV2BodyJSONColumn], nil+ if key.Name == messageSubField {+ return logsV2Columns[messageSubColumn], nil+ }+ return logsV2Columns[LogsV2BodyV2Column], nil}// Fall back to legacy body columnreturn logsV2Columns["body"], nilcase telemetrytypes.FieldContextLog, telemetrytypes.FieldContextUnspecified:+ if key.Name == LogsV2BodyColumn && querybuilder.BodyJSONQueryEnabled {+ return logsV2Columns[messageSubColumn], nil+ }col, ok := logsV2Columns[key.Name]if !ok {// check if the key has body JSON searchif strings.HasPrefix(key.Name, telemetrytypes.BodyJSONStringSearchPrefix) {- // Use body_json if feature flag is enabled and we have a body condition builder+ // Use body_v2 if feature flag is enabled and we have a body condition builderif querybuilder.BodyJSONQueryEnabled {- return logsV2Columns[LogsV2BodyJSONColumn], nil+ return logsV2Columns[LogsV2BodyV2Column], nil}// Fall back to legacy body columnreturn logsV2Columns["body"], nil@@ -138,6 +144,10 @@ func (m *fieldMapper) FieldFor(ctx context.Context, key *telemetrytypes.Telemetr}return fmt.Sprintf("multiIf(%s.`%s` IS NOT NULL, %s.`%s`::String, mapContains(%s, '%s'), %s, NULL)", column.Name, key.Name, column.Name, key.Name, oldColumn.Name, key.Name, oldKeyName), nilcase telemetrytypes.FieldContextBody:+ if key.Name == messageSubField {+ return messageSubColumn, nil+ }+if key.JSONDataType == nil {return "", qbtypes.ErrColumnNotFound}@@ -246,34 +256,37 @@ func (m *fieldMapper) buildFieldForJSON(key *telemetrytypes.TelemetryFieldKey) (node := plan[0]expr := fmt.Sprintf("dynamicElement(%s, '%s')", node.FieldPath(), node.TerminalConfig.ElemType.StringValue())- if key.Materialized {- if len(plan) < 2 {- return "", errors.Newf(errors.TypeUnexpected, CodePromotedPlanMissing,- "plan length is less than 2 for promoted path: %s", key.Name)- }-- node := plan[1]- promotedExpr := fmt.Sprintf(- "dynamicElement(%s, '%s')",- node.FieldPath(),- node.TerminalConfig.ElemType.StringValue(),- )-- // dynamicElement returns NULL for scalar types or an empty array for array types.- if node.TerminalConfig.ElemType.IsArray {- expr = fmt.Sprintf(- "if(length(%s) > 0, %s, %s)",- promotedExpr,- promotedExpr,- expr,- )- } else {- // promoted column first then body_json column- // TODO(Piyush): Change this in future for better performance- expr = fmt.Sprintf("coalesce(%s, %s)", promotedExpr, expr)- }-- }+ // TODO(Piyush): Promoted path logic commented out. Materialized now means type hint+ // promotion will be extracted from key field evolution+ // (direct sub-column access), not a promoted body_promoted.* column.+ // if key.Materialized {+ // if len(plan) < 2 {+ // return "", errors.Newf(errors.TypeUnexpected, CodePromotedPlanMissing,+ // "plan length is less than 2 for promoted path: %s", key.Name)+ // }++ // node := plan[1]+ // promotedExpr := fmt.Sprintf(+ // "dynamicElement(%s, '%s')",+ // node.FieldPath(),+ // node.TerminalConfig.ElemType.StringValue(),+ // )++ // // dynamicElement returns NULL for scalar types or an empty array for array types.+ // if node.TerminalConfig.ElemType.IsArray {+ // expr = fmt.Sprintf(+ // "if(length(%s) > 0, %s, %s)",+ // promotedExpr,+ // promotedExpr,+ // expr,+ // )+ // } else {+ // // promoted column first then body_json column+ // // TODO(Piyush): Change this in future for better performance+ // expr = fmt.Sprintf("coalesce(%s, %s)", promotedExpr, expr)+ // }++ // }return expr, nil}diff --git a/pkg/telemetrylogs/json_condition_builder.go b/pkg/telemetrylogs/json_condition_builder.goindex c0e1b0e6df..0665317493 100644--- a/pkg/telemetrylogs/json_condition_builder.go+++ b/pkg/telemetrylogs/json_condition_builder.go@@ -30,7 +30,7 @@ func NewJSONConditionBuilder(key *telemetrytypes.TelemetryFieldKey, valueType tereturn &jsonConditionBuilder{key: key, valueType: telemetrytypes.MappingFieldDataTypeToJSONDataType[valueType]}}-// BuildCondition builds the full WHERE condition for body_json JSON paths+// BuildCondition builds the full WHERE condition for body_v2 JSON pathsfunc (c *jsonConditionBuilder) buildJSONCondition(operator qbtypes.FilterOperator, value any, sb *sqlbuilder.SelectBuilder) (string, error) {conditions := []string{}for _, node := range c.key.JSONPlan {@@ -40,6 +40,7 @@ func (c *jsonConditionBuilder) buildJSONCondition(operator qbtypes.FilterOperato}conditions = append(conditions, condition)}+return sb.Or(conditions...), nil}@@ -288,9 +289,9 @@ func (c *jsonConditionBuilder) applyOperator(sb *sqlbuilder.SelectBuilder, field}return sb.NotIn(fieldExpr, values...), nilcase qbtypes.FilterOperatorExists:- return fmt.Sprintf("%s IS NOT NULL", fieldExpr), nil+ return sb.IsNotNull(fieldExpr), nilcase qbtypes.FilterOperatorNotExists:- return fmt.Sprintf("%s IS NULL", fieldExpr), nil+ return sb.IsNull(fieldExpr), nil// between and not betweencase qbtypes.FilterOperatorBetween, qbtypes.FilterOperatorNotBetween:values, ok := value.([]any)diff --git a/pkg/telemetrylogs/json_stmt_builder_test.go b/pkg/telemetrylogs/json_stmt_builder_test.goindex 1590bf8e0b..7aa5839beb 100644--- a/pkg/telemetrylogs/json_stmt_builder_test.go+++ b/pkg/telemetrylogs/json_stmt_builder_test.go@@ -2,8 +2,6 @@ package telemetrylogsimport ("context"- "slices"- "strings""testing""time"@@ -17,10 +15,9 @@ import ()func TestStmtBuilderTimeSeriesBodyGroupByJSON(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t)cases := []struct {@@ -97,11 +94,13 @@ func TestStmtBuilderTimeSeriesBodyGroupByJSON(t *testing.T) {}}+/* Promoted path tests commented out — Materialized now means type hint (direct sub-column),+ not a body_promoted.* column. These tests assumed the old coalesce(body_promoted.x, body_v2.x) path.+func TestStmtBuilderTimeSeriesBodyGroupByPromoted(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t, "user.age", "user.name")cases := []struct {@@ -158,12 +157,12 @@ func TestStmtBuilderTimeSeriesBodyGroupByPromoted(t *testing.T) {})}}+*/func TestStatementBuilderListQueryBodyHas(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t)cases := []struct {@@ -182,7 +181,7 @@ func TestStatementBuilderListQueryBodyHas(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (has(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?) OR has(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (has(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?) OR has(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), 1.65, 1.65, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,jsondatatype=Array(Dynamic)].",@@ -199,7 +198,7 @@ func TestStatementBuilderListQueryBodyHas(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND hasAll(dynamicElement(body_v2.`user.permissions`, 'Array(Nullable(String))'), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND hasAll(dynamicElement(body_v2.`user.permissions`, 'Array(Nullable(String))'), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), []any{[]any{"read", "write"}}, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -213,7 +212,7 @@ func TestStatementBuilderListQueryBodyHas(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND hasAny(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->arrayConcat(arrayMap(`body_v2.education[].awards`->arrayConcat(arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), arrayMap(`body_v2.education[].awards`->arrayConcat(arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND hasAny(arrayFlatten(arrayConcat(arrayMap(`body_v2.education`->arrayConcat(arrayMap(`body_v2.education[].awards`->arrayConcat(arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), arrayMap(`body_v2.education[].awards`->arrayConcat(arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(`body_v2.education[].awards[].participated`->dynamicElement(`body_v2.education[].awards[].participated`.`members`, 'Array(Nullable(String))'), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->assumeNotNull(dynamicElement(x, 'JSON')), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), []any{[]any{"Piyush", "Tushar"}}, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -238,10 +237,9 @@ func TestStatementBuilderListQueryBodyHas(t *testing.T) {}func TestStatementBuilderListQueryBody(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t)cases := []struct {@@ -260,7 +258,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (dynamicElement(body_v2.`user.name`, 'String') = ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (dynamicElement(body_v2.`user.name`, 'String') = ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "x", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -274,7 +272,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> dynamicElement(`body_v2.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> dynamicElement(`body_v2.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -288,7 +286,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -302,7 +300,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "Iron Award", "Iron Award", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -316,7 +314,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%1.65%", 1.65, "%1.65%", 1.65, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,jsondatatype=Array(Dynamic)]."},},@@ -331,7 +329,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(dynamicElement(`body_v2.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(dynamicElement(`body_v2.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%IIT%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -345,7 +343,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%true%", true, "%true%", true, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,jsondatatype=Array(Dynamic)]."},},@@ -360,7 +358,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%passed%", "passed", "%passed%", "passed", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,jsondatatype=Array(Dynamic)]."},},@@ -375,7 +373,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> toFloat64(x) IN (?, ?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> x IN (?, ?), arrayMap(x->dynamicElement(x, 'Array(Nullable(Float64))'), arrayFilter(x->(dynamicType(x) = 'Array(Nullable(Float64))'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> toFloat64(x) IN (?, ?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> x IN (?, ?), arrayMap(x->dynamicElement(x, 'Array(Nullable(Float64))'), arrayFilter(x->(dynamicType(x) = 'Array(Nullable(Float64))'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), 1.65, 1.99, 1.65, 1.99, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,jsondatatype=Array(Dynamic)]."},},@@ -390,8 +388,8 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{float64(2), float64(4), float64(2), float64(4), uint64(1747945619), uint64(1747983448), float64(2), float64(4), float64(2), float64(4), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) BETWEEN ? AND ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), float64(2), float64(4), float64(2), float64(4), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},@@ -404,8 +402,8 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{float64(2), float64(4), float64(2), float64(4), uint64(1747945619), uint64(1747983448), float64(2), float64(4), float64(2), float64(4), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> toFloat64(dynamicElement(`body_v2.education[].awards`.`semester`, 'Int64')) IN (?, ?), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), float64(2), float64(4), float64(2), float64(4), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},@@ -418,7 +416,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "sports", "sports", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -432,7 +430,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))')) OR arrayExists(x -> toFloat64OrNull(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))')) OR arrayExists(x -> toFloat64OrNull(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%4%", float64(4), "%4%", float64(4), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `interests[].entities[].reviews[].entries[].metadata[].positions[].ratings` is ambiguous, found 2 different combinations of field context / data type: [name=interests[].entities[].reviews[].entries[].metadata[].positions[].ratings,context=body,datatype=[]int64,jsondatatype=Array(Nullable(Int64)) name=interests[].entities[].reviews[].entries[].metadata[].positions[].ratings,context=body,datatype=[]string,jsondatatype=Array(Nullable(String))]."},},@@ -447,7 +445,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(Int64))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) OR (arrayExists(`body_v2.interests`-> arrayExists(`body_v2.interests[].entities`-> arrayExists(`body_v2.interests[].entities[].reviews`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata`-> arrayExists(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata[].positions`.`ratings`, 'Array(Nullable(String))'))), dynamicElement(`body_v2.interests[].entities[].reviews[].entries[].metadata`.`positions`, 'Array(JSON(max_dynamic_types=0, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews[].entries`.`metadata`, 'Array(JSON(max_dynamic_types=1, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities[].reviews`.`entries`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests[].entities`.`reviews`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')), dynamicElement(`body_v2.interests`.`entities`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')), dynamicElement(body_v2.`interests`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%Good%", "Good", "%Good%", "Good", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `interests[].entities[].reviews[].entries[].metadata[].positions[].ratings` is ambiguous, found 2 different combinations of field context / data type: [name=interests[].entities[].reviews[].entries[].metadata[].positions[].ratings,context=body,datatype=[]int64,jsondatatype=Array(Nullable(Int64)) name=interests[].entities[].reviews[].entries[].metadata[].positions[].ratings,context=body,datatype=[]string,jsondatatype=Array(Nullable(String))]."},},@@ -462,7 +460,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%Civil%", "%Civil%", "%Civil%", "%Civil%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -476,7 +474,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((LOWER(toString(dynamicElement(body_v2.`user.age`, 'Int64'))) LIKE LOWER(?)) OR (LOWER(dynamicElement(body_v2.`user.age`, 'String')) LIKE LOWER(?))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((LOWER(toString(dynamicElement(body_v2.`user.age`, 'Int64'))) LIKE LOWER(?)) OR (LOWER(dynamicElement(body_v2.`user.age`, 'String')) LIKE LOWER(?))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%25%", "%25%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `user.age` is ambiguous, found 2 different combinations of field context / data type: [name=user.age,context=body,datatype=int64,jsondatatype=Int64 name=user.age,context=body,datatype=string,jsondatatype=String]."},},@@ -491,7 +489,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (LOWER(toString(dynamicElement(body_v2.`user.height`, 'Float64'))) LIKE LOWER(?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (LOWER(toString(dynamicElement(body_v2.`user.height`, 'Float64'))) LIKE LOWER(?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%5.8%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -505,7 +503,7 @@ func TestStatementBuilderListQueryBody(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(toString(dynamicElement(`body_v2.education`.`year`, 'Int64'))) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(toString(dynamicElement(`body_v2.education`.`year`, 'Int64'))) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%2020%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -529,11 +527,13 @@ func TestStatementBuilderListQueryBody(t *testing.T) {}}+/* Promoted path list-query tests commented out — Materialized now means type hint+ (direct sub-column access), not a body_promoted.* column.+func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t, "education", "tags")cases := []struct {@@ -552,7 +552,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND has(if(length(dynamicElement(body_promoted.`tags`, 'Array(Nullable(String))')) > 0, dynamicElement(body_promoted.`tags`, 'Array(Nullable(String))'), dynamicElement(body_v2.`tags`, 'Array(Nullable(String))')), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND has(if(length(dynamicElement(body_promoted.`tags`, 'Array(Nullable(String))')) > 0, dynamicElement(body_promoted.`tags`, 'Array(Nullable(String))'), dynamicElement(body_v2.`tags`, 'Array(Nullable(String))')), ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "production", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -566,7 +566,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> dynamicElement(`body_v2.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> dynamicElement(`body_promoted.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> dynamicElement(`body_v2.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> dynamicElement(`body_promoted.education`.`name`, 'String') IS NOT NULL, dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -580,7 +580,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') IS NOT NULL, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') IS NOT NULL, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -594,7 +594,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') = ?, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`name`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "Iron Award", "Iron Award", "Iron Award", "Iron Award", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -608,7 +608,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toFloat64(x) = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> toFloat64(x) = ?, arrayMap(x->dynamicElement(x, 'Float64'), arrayFilter(x->(dynamicType(x) = 'Float64'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%1.65%", 1.65, "%1.65%", 1.65, "%1.65%", 1.65, "%1.65%", 1.65, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,materialized=true,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,materialized=true,jsondatatype=Array(Dynamic)]."},},@@ -623,7 +623,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(dynamicElement(`body_v2.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> LOWER(dynamicElement(`body_promoted.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> LOWER(dynamicElement(`body_v2.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> LOWER(dynamicElement(`body_promoted.education`.`name`, 'String')) LIKE LOWER(?), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%IIT%", "%IIT%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -637,7 +637,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> x = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'Bool'), arrayFilter(x->(dynamicType(x) = 'Bool'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%true%", true, "%true%", true, "%true%", true, "%true%", true, "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,materialized=true,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,materialized=true,jsondatatype=Array(Dynamic)]."},},@@ -652,7 +652,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND ((arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_v2.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(toString(x)) LIKE LOWER(?), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))')) OR arrayExists(x -> toString(x) = ?, dynamicElement(`body_promoted.education`.`parameters`, 'Array(Nullable(Float64))'))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) OR (arrayExists(`body_v2.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_v2.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(x -> LOWER(x) LIKE LOWER(?), arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)')))) OR arrayExists(x -> x = ?, arrayMap(x->dynamicElement(x, 'String'), arrayFilter(x->(dynamicType(x) = 'String'), dynamicElement(`body_promoted.education`.`parameters`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%passed%", "passed", "%passed%", "passed", "%passed%", "passed", "%passed%", "passed", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},Warnings: []string{"Key `education[].parameters` is ambiguous, found 2 different combinations of field context / data type: [name=education[].parameters,context=body,datatype=[]float64,materialized=true,jsondatatype=Array(Nullable(Float64)) name=education[].parameters,context=body,datatype=[]dynamic,materialized=true,jsondatatype=Array(Dynamic)]."},},@@ -667,7 +667,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> dynamicElement(`body_v2.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`type`, 'String') = ?, dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> dynamicElement(`body_promoted.education[].awards`.`type`, 'String') = ?, arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "sports", "sports", "sports", "sports", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -681,7 +681,7 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> (arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=4))')), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=16))')) OR arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> (arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (arrayExists(`body_v2.education`-> (arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=0))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_v2.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=0))')) OR arrayExists(`body_v2.education[].awards`-> (arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_v2.education[].awards[].participated`-> arrayExists(`body_v2.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_v2.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_v2.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_v2.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_v2.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=0))')) OR arrayExists(`body_promoted.education`-> (arrayExists(`body_promoted.education[].awards`-> (arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=2, max_dynamic_paths=4))')), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=4, max_dynamic_paths=16))')) OR arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(Dynamic)'))))), dynamicElement(`body_promoted.education`.`awards`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')) OR arrayExists(`body_promoted.education[].awards`-> (arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=8, max_dynamic_paths=64))')), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')) OR arrayExists(`body_promoted.education[].awards[].participated`-> arrayExists(`body_promoted.education[].awards[].participated[].team`-> LOWER(dynamicElement(`body_promoted.education[].awards[].participated[].team`.`branch`, 'String')) LIKE LOWER(?), dynamicElement(`body_promoted.education[].awards[].participated`.`team`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))')), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education[].awards`.`participated`, 'Array(Dynamic)'))))), arrayMap(x->dynamicElement(x, 'JSON'), arrayFilter(x->(dynamicType(x) = 'JSON'), dynamicElement(`body_promoted.education`.`awards`, 'Array(Dynamic)'))))), dynamicElement(body_promoted.`education`, 'Array(JSON(max_dynamic_types=16, max_dynamic_paths=256))'))) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",Args: []any{uint64(1747945619), uint64(1747983448), "%Civil%", "%Civil%", "%Civil%", "%Civil%", "%Civil%", "%Civil%", "%Civil%", "%Civil%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,@@ -705,27 +705,14 @@ func TestStatementBuilderListQueryBodyPromoted(t *testing.T) {})}}+*/func TestStatementBuilderListQueryBodyMessage(t *testing.T) {- enableBodyJSONQuery(t)- defer func() {- disableBodyJSONQuery(t)- }()+ enable, disable := jsonQueryTestUtil(t)+ enable()+ defer disable()statementBuilder := buildJSONTestStatementBuilder(t)- indexed := []*telemetrytypes.TelemetryFieldKey{- {- Name: "message",- Indexes: []telemetrytypes.JSONDataTypeIndex{- {- Type: telemetrytypes.String,- ColumnExpression: "body_promoted.message",- IndexExpression: "(lower(assumeNotNull(dynamicElement(body_promoted.message, 'String'))))",- },- },- },- }- testAddIndexedPaths(t, statementBuilder, indexed...)cases := []struct {name stringrequestType qbtypes.RequestType@@ -734,16 +721,16 @@ func TestStatementBuilderListQueryBodyMessage(t *testing.T) {expectedErr error}{{- name: "body.message Exists",+ name: "message Exists",requestType: qbtypes.RequestTypeRaw,query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{Signal: telemetrytypes.SignalLogs,- Filter: &qbtypes.Filter{Expression: "body.message Exists"},+ Filter: &qbtypes.Filter{Expression: "message Exists"},Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (dynamicElement(body_v2.`message`, 'String') IS NOT NULL OR dynamicElement(body_promoted.`message`, 'String') IS NOT NULL) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{uint64(1747945619), uint64(1747983448), "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body_v2.message <> ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},@@ -756,8 +743,8 @@ func TestStatementBuilderListQueryBodyMessage(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (dynamicElement(body_v2.`message`, 'String') = ? OR dynamicElement(body_promoted.`message`, 'String') = ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{uint64(1747945619), uint64(1747983448), "", "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body_v2.message = ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},@@ -770,22 +757,22 @@ func TestStatementBuilderListQueryBodyMessage(t *testing.T) {Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (dynamicElement(body_v2.`message`, 'String') = ? OR dynamicElement(body_promoted.`message`, 'String') = ?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{uint64(1747945619), uint64(1747983448), "Iron Award", "Iron Award", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body_v2.message = ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "Iron Award", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},{- name: "body.message contains 'Iron Award'",+ name: "message contains 'Iron Award'",requestType: qbtypes.RequestTypeRaw,query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{Signal: telemetrytypes.SignalLogs,- Filter: &qbtypes.Filter{Expression: "body.message Contains 'Iron Award'"},+ Filter: &qbtypes.Filter{Expression: "message Contains 'Iron Award'"},Limit: 10,},expected: qbtypes.Statement{- Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, body_v2, body_promoted, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND (LOWER(dynamicElement(body_v2.`message`, 'String')) LIKE LOWER(?) OR LOWER(dynamicElement(body_promoted.`message`, 'String')) LIKE LOWER(?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",- Args: []any{uint64(1747945619), uint64(1747983448), "%Iron Award%", "%Iron Award%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND LOWER(body_v2.message) LIKE LOWER(?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "%Iron Award%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},},expectedErr: nil,},@@ -793,9 +780,7 @@ func TestStatementBuilderListQueryBodyMessage(t *testing.T) {for _, c := range cases {t.Run(c.name, func(t *testing.T) {-q, err := statementBuilder.Build(context.Background(), 1747947419000, 1747983448000, c.requestType, c.query, nil)-if c.expectedErr != nil {require.Error(t, err)require.Contains(t, err.Error(), c.expectedErr.Error())@@ -809,19 +794,17 @@ func TestStatementBuilderListQueryBodyMessage(t *testing.T) {}}-func buildTestTelemetryMetadataStore(t *testing.T, promotedPaths ...string) *telemetrytypestest.MockMetadataStore {+func buildTestTelemetryMetadataStore(t *testing.T) *telemetrytypestest.MockMetadataStore {mockMetadataStore := telemetrytypestest.NewMockMetadataStore()-+ mockMetadataStore.SetStaticFields(IntrinsicFields)types, _ := telemetrytypes.TestJSONTypeSet()for path, jsonTypes := range types {- promoted := false+ // promoted := false- split := strings.Split(path, telemetrytypes.ArraySep)- if path == "message" {- promoted = true- } else if slices.Contains(promotedPaths, split[0]) {- promoted = true- }+ // split := strings.Split(path, telemetrytypes.ArraySep)+ // if slices.Contains(promotedPaths, split[0]) {+ // promoted = true+ // }// Create a TelemetryFieldKey for each JSONDataType for this path// Since a path can have multiple types, we create one key per typefor _, jsonType := range jsonTypes {@@ -831,10 +814,10 @@ func buildTestTelemetryMetadataStore(t *testing.T, promotedPaths ...string) *telFieldContext: telemetrytypes.FieldContextBody,FieldDataType: telemetrytypes.MappingJSONDataTypeToFieldDataType[jsonType],JSONDataType: &jsonType,- Materialized: promoted,+ // Materialized: promoted,}err := key.SetJSONAccessPlan(telemetrytypes.JSONColumnMetadata{- BaseColumn: LogsV2BodyJSONColumn,+ BaseColumn: LogsV2BodyV2Column,PromotedColumn: LogsV2BodyPromotedColumn,}, types)require.NoError(t, err)@@ -845,16 +828,19 @@ func buildTestTelemetryMetadataStore(t *testing.T, promotedPaths ...string) *telreturn mockMetadataStore}-func buildJSONTestStatementBuilder(t *testing.T, promotedPaths ...string) *logQueryStatementBuilder {- mockMetadataStore := buildTestTelemetryMetadataStore(t, promotedPaths...)+func buildJSONTestStatementBuilder(t *testing.T) *logQueryStatementBuilder {+ mockMetadataStore := buildTestTelemetryMetadataStore(t)fm := NewFieldMapper()cb := NewConditionBuilder(fm)+ resourceFilterFM := resourcefilter.NewFieldMapper()+ resourceFilterCB := resourcefilter.NewConditionBuilder(resourceFilterFM)+aggExprRewriter := querybuilder.NewAggExprRewriter(instrumentationtest.New().ToProviderSettings(), nil, fm, cb, nil)resourceFilterStmtBuilder := resourcefilter.NewLogResourceFilterStatementBuilder(instrumentationtest.New().ToProviderSettings(),- fm,- cb,+ resourceFilterFM,+ resourceFilterCB,mockMetadataStore,DefaultFullTextColumn,GetBodyJSONKey,@@ -874,23 +860,13 @@ func buildJSONTestStatementBuilder(t *testing.T, promotedPaths ...string) *logQureturn statementBuilder}-func testAddIndexedPaths(t *testing.T, statementBuilder *logQueryStatementBuilder, telemetryFieldKeys ...*telemetrytypes.TelemetryFieldKey) {- mockMetadataStore := statementBuilder.metadataStore.(*telemetrytypestest.MockMetadataStore)- for _, key := range telemetryFieldKeys {- if strings.Contains(key.Name, telemetrytypes.ArraySep) || strings.Contains(key.Name, telemetrytypes.ArrayAnyIndex) {- t.Fatalf("array paths are not supported: %s", key.Name)- }-- for _, storedKey := range mockMetadataStore.KeysMap[key.Name] {- storedKey.Indexes = append(storedKey.Indexes, key.Indexes...)- }+func jsonQueryTestUtil(_ *testing.T) (func(), func()) {+ enable := func() {+ querybuilder.BodyJSONQueryEnabled = true+ }+ disable := func() {+ querybuilder.BodyJSONQueryEnabled = false}-}--func enableBodyJSONQuery(_ *testing.T) {- querybuilder.BodyJSONQueryEnabled = true-}-func disableBodyJSONQuery(_ *testing.T) {- querybuilder.BodyJSONQueryEnabled = false+ return enable, disable}diff --git a/pkg/telemetrylogs/statement_builder.go b/pkg/telemetrylogs/statement_builder.goindex 4075191472..1bce288aa2 100644--- a/pkg/telemetrylogs/statement_builder.go+++ b/pkg/telemetrylogs/statement_builder.go@@ -65,7 +65,7 @@ func (b *logQueryStatementBuilder) Build(start = querybuilder.ToNanoSecs(start)end = querybuilder.ToNanoSecs(end)- keySelectors := getKeySelectors(query)+ keySelectors, warnings := getKeySelectors(query)keys, _, err := b.metadataStore.GetKeysMulti(ctx, keySelectors)if err != nil {return nil, err@@ -76,20 +76,29 @@ func (b *logQueryStatementBuilder) Build(// Create SQL builderq := sqlbuilder.NewSelectBuilder()+ var stmt *qbtypes.Statementswitch requestType {case qbtypes.RequestTypeRaw, qbtypes.RequestTypeRawStream:- return b.buildListQuery(ctx, q, query, start, end, keys, variables)+ stmt, err = b.buildListQuery(ctx, q, query, start, end, keys, variables)case qbtypes.RequestTypeTimeSeries:- return b.buildTimeSeriesQuery(ctx, q, query, start, end, keys, variables)+ stmt, err = b.buildTimeSeriesQuery(ctx, q, query, start, end, keys, variables)case qbtypes.RequestTypeScalar:- return b.buildScalarQuery(ctx, q, query, start, end, keys, false, variables)+ stmt, err = b.buildScalarQuery(ctx, q, query, start, end, keys, false, variables)+ default:+ return nil, errors.NewInvalidInputf(errors.CodeInvalidInput, "unsupported request type: %s", requestType)}- return nil, errors.NewInvalidInputf(errors.CodeInvalidInput, "unsupported request type: %s", requestType)+ if err != nil {+ return nil, err+ }++ stmt.Warnings = append(stmt.Warnings, warnings...)+ return stmt, nil}-func getKeySelectors(query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]) []*telemetrytypes.FieldKeySelector {+func getKeySelectors(query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]) ([]*telemetrytypes.FieldKeySelector, []string) {var keySelectors []*telemetrytypes.FieldKeySelector+ var warnings []stringfor idx := range query.Aggregations {aggExpr := query.Aggregations[idx]@@ -136,7 +145,19 @@ func getKeySelectors(query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]) []keySelectors[idx].SelectorMatchType = telemetrytypes.FieldSelectorMatchTypeExact}- return keySelectors+ // When the new JSON body experience is enabled, warn the user if they use the bare+ // "body" key in the filter — queries on plain "body" default to body.message:string.+ // TODO(Piyush): Setup better for coming FTS support.+ if querybuilder.BodyJSONQueryEnabled {+ for _, sel := range keySelectors {+ if sel.Name == LogsV2BodyColumn {+ warnings = append(warnings, bodySearchDefaultWarning)+ break+ }+ }+ }++ return keySelectors, warnings}func (b *logQueryStatementBuilder) adjustKeys(ctx context.Context, keys map[string][]*telemetrytypes.TelemetryFieldKey, query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation], requestType qbtypes.RequestType) qbtypes.QueryBuilderQuery[qbtypes.LogAggregation] {@@ -203,7 +224,6 @@ func (b *logQueryStatementBuilder) adjustKeys(ctx context.Context, keys map[stri}func (b *logQueryStatementBuilder) adjustKey(key *telemetrytypes.TelemetryFieldKey, keys map[string][]*telemetrytypes.TelemetryFieldKey) []string {-// First check if it matches with any intrinsic fieldsvar intrinsicOrCalculatedField telemetrytypes.TelemetryFieldKeyif _, ok := IntrinsicFields[key.Name]; ok {@@ -212,7 +232,6 @@ func (b *logQueryStatementBuilder) adjustKey(key *telemetrytypes.TelemetryFieldK}return querybuilder.AdjustKey(key, keys, nil)-}// buildListQuery builds a query for list panel type@@ -249,11 +268,7 @@ func (b *logQueryStatementBuilder) buildListQuery(sb.SelectMore(LogsV2SeverityNumberColumn)sb.SelectMore(LogsV2ScopeNameColumn)sb.SelectMore(LogsV2ScopeVersionColumn)- sb.SelectMore(LogsV2BodyColumn)- if querybuilder.BodyJSONQueryEnabled {- sb.SelectMore(LogsV2BodyJSONColumn)- sb.SelectMore(LogsV2BodyPromotedColumn)- }+ sb.SelectMore(bodyAliasExpression())sb.SelectMore(LogsV2AttributesStringColumn)sb.SelectMore(LogsV2AttributesNumberColumn)sb.SelectMore(LogsV2AttributesBoolColumn)diff --git a/pkg/telemetrylogs/stmt_builder_test.go b/pkg/telemetrylogs/stmt_builder_test.goindex 15810c966a..b54f75b302 100644--- a/pkg/telemetrylogs/stmt_builder_test.go+++ b/pkg/telemetrylogs/stmt_builder_test.go@@ -5,6 +5,7 @@ import ("testing""time"+ "github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/instrumentation/instrumentationtest""github.com/SigNoz/signoz/pkg/querybuilder""github.com/SigNoz/signoz/pkg/querybuilder/resourcefilter"@@ -886,3 +887,246 @@ func TestAdjustKey(t *testing.T) {})}}++func TestStmtBuilderBodyField(t *testing.T) {+ cases := []struct {+ name string+ requestType qbtypes.RequestType+ query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]+ enableBodyJSONQuery bool+ expected qbtypes.Statement+ expectedErr error+ }{+ {+ name: "body_exists",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body Exists"},+ Limit: 10,+ },+ enableBodyJSONQuery: true,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body_v2.message <> ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Warnings: []string{bodySearchDefaultWarning},+ },+ expectedErr: nil,+ },+ {+ name: "body_exists_disabled",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body Exists"},+ Limit: 10,+ },+ enableBodyJSONQuery: false,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body <> ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ },+ expectedErr: nil,+ },+ {+ name: "body_empty",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body == ''"},+ Limit: 10,+ },+ enableBodyJSONQuery: true,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body_v2.message = ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Warnings: []string{bodySearchDefaultWarning},+ },+ expectedErr: nil,+ },+ {+ name: "body_empty_disabled",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body == ''"},+ Limit: 10,+ },+ enableBodyJSONQuery: false,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND body = ? AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ },+ expectedErr: nil,+ },+ {+ name: "body_contains",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body CONTAINS 'error'"},+ Limit: 10,+ },+ enableBodyJSONQuery: true,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND LOWER(body_v2.message) LIKE LOWER(?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "%error%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ Warnings: []string{bodySearchDefaultWarning},+ },+ expectedErr: nil,+ },+ {+ name: "body_contains_disabled",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "body CONTAINS 'error'"},+ Limit: 10,+ },+ enableBodyJSONQuery: false,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND LOWER(body) LIKE LOWER(?) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "%error%", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ },+ expectedErr: nil,+ },+ }++ fm := NewFieldMapper()+ cb := NewConditionBuilder(fm)++ enable, disable := jsonQueryTestUtil(t)+ defer disable()+ for _, c := range cases {+ t.Run(c.name, func(t *testing.T) {+ if c.enableBodyJSONQuery {+ enable()+ } else {+ disable()+ }+ // build the key map after enabling/disabling body JSON query+ mockMetadataStore := telemetrytypestest.NewMockMetadataStore()+ for _, field := range IntrinsicFields {+ f := field+ mockMetadataStore.KeysMap[field.Name] = append(mockMetadataStore.KeysMap[field.Name], &f)+ }+ aggExprRewriter := querybuilder.NewAggExprRewriter(instrumentationtest.New().ToProviderSettings(), nil, fm, cb, nil)+ resourceFilterStmtBuilder := resourceFilterStmtBuilder()+ statementBuilder := NewLogQueryStatementBuilder(+ instrumentationtest.New().ToProviderSettings(),+ mockMetadataStore,+ fm,+ cb,+ resourceFilterStmtBuilder,+ aggExprRewriter,+ DefaultFullTextColumn,+ GetBodyJSONKey,+ )++ q, err := statementBuilder.Build(context.Background(), 1747947419000, 1747983448000, c.requestType, c.query, nil)+ if c.expectedErr != nil {+ require.Error(t, err)+ require.Contains(t, err.Error(), c.expectedErr.Error())+ } else {+ if err != nil {+ _, _, _, _, _, add := errors.Unwrapb(err)+ t.Logf("error additionals: %v", add)+ }+ require.NoError(t, err)+ require.Equal(t, c.expected.Query, q.Query)+ require.Equal(t, c.expected.Args, q.Args)+ require.Equal(t, c.expected.Warnings, q.Warnings)+ }+ })+ }+}++func TestStmtBuilderBodyFullTextSearch(t *testing.T) {+ cases := []struct {+ name string+ requestType qbtypes.RequestType+ query qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]+ enableBodyJSONQuery bool+ expected qbtypes.Statement+ expectedErr error+ }{+ {+ name: "body_contains",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "'error'"},+ Limit: 10,+ },+ enableBodyJSONQuery: true,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body_v2 as body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND match(LOWER(body_v2.message), LOWER(?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "error", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ },+ expectedErr: nil,+ },+ {+ name: "body_contains_disabled",+ requestType: qbtypes.RequestTypeRaw,+ query: qbtypes.QueryBuilderQuery[qbtypes.LogAggregation]{+ Signal: telemetrytypes.SignalLogs,+ Filter: &qbtypes.Filter{Expression: "'error'"},+ Limit: 10,+ },+ enableBodyJSONQuery: false,+ expected: qbtypes.Statement{+ Query: "WITH __resource_filter AS (SELECT fingerprint FROM signoz_logs.distributed_logs_v2_resource WHERE true AND seen_at_ts_bucket_start >= ? AND seen_at_ts_bucket_start <= ?) SELECT timestamp, id, trace_id, span_id, trace_flags, severity_text, severity_number, scope_name, scope_version, body, attributes_string, attributes_number, attributes_bool, resources_string, scope_string FROM signoz_logs.distributed_logs_v2 WHERE resource_fingerprint GLOBAL IN (SELECT fingerprint FROM __resource_filter) AND match(LOWER(body), LOWER(?)) AND timestamp >= ? AND ts_bucket_start >= ? AND timestamp < ? AND ts_bucket_start <= ? LIMIT ?",+ Args: []any{uint64(1747945619), uint64(1747983448), "error", "1747947419000000000", uint64(1747945619), "1747983448000000000", uint64(1747983448), 10},+ },+ expectedErr: nil,+ },+ }++ fm := NewFieldMapper()+ cb := NewConditionBuilder(fm)++ enable, disable := jsonQueryTestUtil(t)+ defer disable()+ for _, c := range cases {+ t.Run(c.name, func(t *testing.T) {+ if c.enableBodyJSONQuery {+ enable()+ } else {+ disable()+ }+ // build the key map after enabling/disabling body JSON query+ mockMetadataStore := telemetrytypestest.NewMockMetadataStore()+ for _, field := range IntrinsicFields {+ f := field+ mockMetadataStore.KeysMap[field.Name] = append(mockMetadataStore.KeysMap[field.Name], &f)+ }+ aggExprRewriter := querybuilder.NewAggExprRewriter(instrumentationtest.New().ToProviderSettings(), nil, fm, cb, nil)+ resourceFilterStmtBuilder := resourceFilterStmtBuilder()+ statementBuilder := NewLogQueryStatementBuilder(+ instrumentationtest.New().ToProviderSettings(),+ mockMetadataStore,+ fm,+ cb,+ resourceFilterStmtBuilder,+ aggExprRewriter,+ DefaultFullTextColumn,+ GetBodyJSONKey,+ )++ q, err := statementBuilder.Build(context.Background(), 1747947419000, 1747983448000, c.requestType, c.query, nil)+ if c.expectedErr != nil {+ require.Error(t, err)+ require.Contains(t, err.Error(), c.expectedErr.Error())+ } else {+ if err != nil {+ _, _, _, _, _, add := errors.Unwrapb(err)+ t.Logf("error additionals: %v", add)+ }+ require.NoError(t, err)+ require.Equal(t, c.expected.Query, q.Query)+ require.Equal(t, c.expected.Args, q.Args)+ require.Equal(t, c.expected.Warnings, q.Warnings)+ }+ })+ }+}diff --git a/pkg/telemetrylogs/test_data.go b/pkg/telemetrylogs/test_data.goindex 4b208e5b63..ae52227101 100644--- a/pkg/telemetrylogs/test_data.go+++ b/pkg/telemetrylogs/test_data.go@@ -27,13 +27,6 @@ func buildCompleteFieldKeyMap() map[string][]*telemetrytypes.TelemetryFieldKey {FieldDataType: telemetrytypes.FieldDataTypeString,},},- "body": {- {- Name: "body",- FieldContext: telemetrytypes.FieldContextLog,- FieldDataType: telemetrytypes.FieldDataTypeString,- },- },"http.status_code": {{Name: "http.status_code",@@ -938,6 +931,13 @@ func buildCompleteFieldKeyMap() map[string][]*telemetrytypes.TelemetryFieldKey {Materialized: true,},},+ "body": {+ {+ Name: "body",+ FieldContext: telemetrytypes.FieldContextLog,+ FieldDataType: telemetrytypes.FieldDataTypeString,+ },+ },}for _, keys := range keysMap {@@ -945,6 +945,7 @@ func buildCompleteFieldKeyMap() map[string][]*telemetrytypes.TelemetryFieldKey {key.Signal = telemetrytypes.SignalLogs}}+return keysMap}diff --git a/pkg/telemetrymetadata/body_json_metadata.go b/pkg/telemetrymetadata/body_json_metadata.goindex 3a6e456af2..11d6938b4e 100644--- a/pkg/telemetrymetadata/body_json_metadata.go+++ b/pkg/telemetrymetadata/body_json_metadata.go@@ -54,6 +54,7 @@ func (t *telemetryMetaStore) fetchBodyJSONPaths(ctx context.Context,instrumentationtypes.CodeNamespace: "metadata",instrumentationtypes.CodeFunctionName: "fetchBodyJSONPaths",})+query, args, limit := buildGetBodyJSONPathsQuery(fieldKeySelectors)rows, err := t.telemetrystore.ClickhouseDB().Query(ctx, query, args...)if err != nil {@@ -184,7 +185,6 @@ func buildGetBodyJSONPathsQuery(fieldKeySelectors []*telemetrytypes.FieldKeySelelimit += fieldKeySelector.Limit}sb.Where(sb.Or(orClauses...))-// Group by path to get unique paths with aggregated typessb.GroupBy("path")@@ -319,7 +319,7 @@ func (t *telemetryMetaStore) ListJSONValues(ctx context.Context, path string, liif promoted {path = telemetrylogs.BodyPromotedColumnPrefix + path} else {- path = telemetrylogs.BodyJSONColumnPrefix + path+ path = telemetrylogs.BodyV2ColumnPrefix + path}from := fmt.Sprintf("%s.%s", telemetrylogs.DBName, telemetrylogs.LogsV2TableName)@@ -522,7 +522,7 @@ func (t *telemetryMetaStore) GetPromotedPaths(ctx context.Context, paths ...stri// TODO(Piyush): Remove this functionfunc CleanPathPrefixes(path string) string {path = strings.TrimPrefix(path, telemetrytypes.BodyJSONStringSearchPrefix)- path = strings.TrimPrefix(path, telemetrylogs.BodyJSONColumnPrefix)+ path = strings.TrimPrefix(path, telemetrylogs.BodyV2ColumnPrefix)path = strings.TrimPrefix(path, telemetrylogs.BodyPromotedColumnPrefix)return path}diff --git a/pkg/telemetrymetadata/metadata.go b/pkg/telemetrymetadata/metadata.goindex 3a58ab5d0c..87f7c39d11 100644--- a/pkg/telemetrymetadata/metadata.go+++ b/pkg/telemetrymetadata/metadata.go@@ -102,7 +102,7 @@ func NewTelemetryMetaStore(jsonColumnMetadata: map[telemetrytypes.Signal]map[telemetrytypes.FieldContext]telemetrytypes.JSONColumnMetadata{telemetrytypes.SignalLogs: {telemetrytypes.FieldContextBody: telemetrytypes.JSONColumnMetadata{- BaseColumn: telemetrylogs.LogsV2BodyJSONColumn,+ BaseColumn: telemetrylogs.LogsV2BodyV2Column,PromotedColumn: telemetrylogs.LogsV2BodyPromotedColumn,},},diff --git a/pkg/types/telemetrytypes/json_access_plan.go b/pkg/types/telemetrytypes/json_access_plan.goindex 03a5454b06..6102152fd2 100644--- a/pkg/types/telemetrytypes/json_access_plan.go+++ b/pkg/types/telemetrytypes/json_access_plan.go@@ -40,7 +40,7 @@ type JSONAccessNode struct {// Node informationName stringIsTerminal bool- isRoot bool // marked true for only body_json and body_json_promoted+ isRoot bool // marked true for only body_v2 and body_promoted// Precomputed type information (single source of truth)AvailableTypes []JSONDataTypediff --git a/pkg/types/telemetrytypes/json_access_plan_test.go b/pkg/types/telemetrytypes/json_access_plan_test.goindex fbf3049218..156f4cf28a 100644--- a/pkg/types/telemetrytypes/json_access_plan_test.go+++ b/pkg/types/telemetrytypes/json_access_plan_test.go@@ -1,12 +1,19 @@package telemetrytypesimport (+ "fmt""testing"+ otelconstants "github.com/SigNoz/signoz-otel-collector/constants""github.com/stretchr/testify/require""gopkg.in/yaml.v3")+const (+ bodyV2Column = otelconstants.BodyV2Column+ bodyPromotedColumn = otelconstants.BodyPromotedColumn+)+// ============================================================================// Helper Functions for Test Data Creation// ============================================================================@@ -109,8 +116,8 @@ func TestNode_Alias(t *testing.T) {}{{name: "Root node returns name as-is",- node: NewRootJSONAccessNode("body_json", 32, 0),- expected: "body_json",+ node: NewRootJSONAccessNode(bodyV2Column, 32, 0),+ expected: bodyV2Column,},{name: "Node without parent returns backticked name",@@ -124,9 +131,9 @@ func TestNode_Alias(t *testing.T) {name: "Node with root parent uses dot separator",node: &JSONAccessNode{Name: "age",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},- expected: "`" + "body_json" + ".age`",+ expected: "`" + bodyV2Column + ".age`",},{name: "Node with non-root parent uses array separator",@@ -134,10 +141,10 @@ func TestNode_Alias(t *testing.T) {Name: "name",Parent: &JSONAccessNode{Name: "education",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},},- expected: "`" + "body_json" + ".education[].name`",+ expected: "`" + bodyV2Column + ".education[].name`",},{name: "Nested array path with multiple levels",@@ -147,11 +154,11 @@ func TestNode_Alias(t *testing.T) {Name: "awards",Parent: &JSONAccessNode{Name: "education",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},},},- expected: "`" + "body_json" + ".education[].awards[].type`",+ expected: "`" + bodyV2Column + ".education[].awards[].type`",},}@@ -173,18 +180,18 @@ func TestNode_FieldPath(t *testing.T) {name: "Simple field path from root",node: &JSONAccessNode{Name: "user",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},// FieldPath() always wraps the field name in backticks- expected: "body_json" + ".`user`",+ expected: bodyV2Column + ".`user`",},{name: "Field path with backtick-required key",node: &JSONAccessNode{Name: "user-name", // requires backtick- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},- expected: "body_json" + ".`user-name`",+ expected: bodyV2Column + ".`user-name`",},{name: "Nested field path",@@ -192,11 +199,11 @@ func TestNode_FieldPath(t *testing.T) {Name: "age",Parent: &JSONAccessNode{Name: "user",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},},// FieldPath() always wraps the field name in backticks- expected: "`" + "body_json" + ".user`.`age`",+ expected: "`" + bodyV2Column + ".user`.`age`",},{name: "Array element field path",@@ -204,11 +211,11 @@ func TestNode_FieldPath(t *testing.T) {Name: "name",Parent: &JSONAccessNode{Name: "education",- Parent: NewRootJSONAccessNode("body_json", 32, 0),+ Parent: NewRootJSONAccessNode(bodyV2Column, 32, 0),},},// FieldPath() always wraps the field name in backticks- expected: "`" + "body_json" + ".education`.`name`",+ expected: "`" + bodyV2Column + ".education`.`name`",},}@@ -236,36 +243,36 @@ func TestPlanJSON_BasicStructure(t *testing.T) {{name: "Simple path not promoted",key: makeKey("user.name", String, false),- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: user.name- column: body_json+ column: %savailableTypes:- StringmaxDynamicTypes: 16isTerminal: trueelemType: String-`,+`, bodyV2Column),},{name: "Simple path promoted",key: makeKey("user.name", String, true),- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: user.name- column: body_json+ column: %savailableTypes:- StringmaxDynamicTypes: 16isTerminal: trueelemType: String- name: user.name- column: body_json_promoted+ column: %savailableTypes:- StringmaxDynamicTypes: 16maxDynamicPaths: 256isTerminal: trueelemType: String-`,+`, bodyV2Column, bodyPromotedColumn),},{name: "Empty path returns error",@@ -278,8 +285,8 @@ func TestPlanJSON_BasicStructure(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {err := tt.key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)if tt.expectErr {require.Error(t, err)@@ -304,9 +311,9 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {{name: "Single array level - JSON branch only",path: "education[].name",- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -318,14 +325,14 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {maxDynamicTypes: 8isTerminal: trueelemType: String-`,+`, bodyV2Column),},{name: "Single array level - both JSON and Dynamic branches",path: "education[].awards[].type",- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -352,14 +359,14 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {maxDynamicPaths: 256isTerminal: trueelemType: String-`,+`, bodyV2Column),},{name: "Deeply nested array path",path: "interests[].entities[].reviews[].entries[].metadata[].positions[].name",- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: interests- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -399,14 +406,14 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {- StringisTerminal: trueelemType: String-`,+`, bodyV2Column),},{name: "ArrayAnyIndex replacement [*] to []",path: "education[*].name",- expectedYAML: `+ expectedYAML: fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -418,7 +425,7 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {maxDynamicTypes: 8isTerminal: trueelemType: String-`,+`, bodyV2Column),},}@@ -426,8 +433,8 @@ func TestPlanJSON_ArrayPaths(t *testing.T) {t.Run(tt.name, func(t *testing.T) {key := makeKey(tt.path, String, false)err := key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)require.NoError(t, err)require.NotNil(t, key.JSONPlan)@@ -445,15 +452,15 @@ func TestPlanJSON_PromotedVsNonPromoted(t *testing.T) {t.Run("Non-promoted plan", func(t *testing.T) {key := makeKey(path, String, false)err := key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)require.NoError(t, err)require.Len(t, key.JSONPlan, 1)- expectedYAML := `+ expectedYAML := fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -480,7 +487,7 @@ func TestPlanJSON_PromotedVsNonPromoted(t *testing.T) {maxDynamicPaths: 256isTerminal: trueelemType: String-`+`, bodyV2Column)got := plansToYAML(t, key.JSONPlan)require.YAMLEq(t, expectedYAML, got)})@@ -488,15 +495,15 @@ func TestPlanJSON_PromotedVsNonPromoted(t *testing.T) {t.Run("Promoted plan", func(t *testing.T) {key := makeKey(path, String, true)err := key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)require.NoError(t, err)require.Len(t, key.JSONPlan, 2)- expectedYAML := `+ expectedYAML := fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -524,7 +531,7 @@ func TestPlanJSON_PromotedVsNonPromoted(t *testing.T) {isTerminal: trueelemType: String- name: education- column: body_json_promoted+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -554,7 +561,7 @@ func TestPlanJSON_PromotedVsNonPromoted(t *testing.T) {maxDynamicPaths: 256isTerminal: trueelemType: String-`+`, bodyV2Column, bodyPromotedColumn)got := plansToYAML(t, key.JSONPlan)require.YAMLEq(t, expectedYAML, got)})@@ -575,11 +582,11 @@ func TestPlanJSON_EdgeCases(t *testing.T) {expectErr: true,},{- name: "Very deep nesting - validates progression doesn't go negative",- path: "interests[].entities[].reviews[].entries[].metadata[].positions[].name",- expectedYAML: `+ name: "Very deep nesting - validates progression doesn't go negative",+ path: "interests[].entities[].reviews[].entries[].metadata[].positions[].name",+ expectedYAML: fmt.Sprintf(`- name: interests- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -619,14 +626,14 @@ func TestPlanJSON_EdgeCases(t *testing.T) {- StringisTerminal: trueelemType: String-`,+`, bodyV2Column),},{- name: "Path with mixed scalar and array types",- path: "education[].type",- expectedYAML: `+ name: "Path with mixed scalar and array types",+ path: "education[].type",+ expectedYAML: fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -639,20 +646,20 @@ func TestPlanJSON_EdgeCases(t *testing.T) {maxDynamicTypes: 8isTerminal: trueelemType: String-`,+`, bodyV2Column),},{- name: "Exists with only array types available",- path: "education",- expectedYAML: `+ name: "Exists with only array types available",+ path: "education",+ expectedYAML: fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16isTerminal: trueelemType: Array(JSON)-`,+`, bodyV2Column),},}@@ -668,8 +675,8 @@ func TestPlanJSON_EdgeCases(t *testing.T) {}key := makeKey(tt.path, keyType, false)err := key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)if tt.expectErr {require.Error(t, err)@@ -687,15 +694,15 @@ func TestPlanJSON_TreeStructure(t *testing.T) {path := "education[].awards[].participated[].team[].branch"key := makeKey(path, String, false)err := key.SetJSONAccessPlan(JSONColumnMetadata{- BaseColumn: "body_json",- PromotedColumn: "body_json_promoted",+ BaseColumn: bodyV2Column,+ PromotedColumn: bodyPromotedColumn,}, types)require.NoError(t, err)require.Len(t, key.JSONPlan, 1)- expectedYAML := `+ expectedYAML := fmt.Sprintf(`- name: education- column: body_json+ column: %savailableTypes:- Array(JSON)maxDynamicTypes: 16@@ -780,7 +787,7 @@ func TestPlanJSON_TreeStructure(t *testing.T) {maxDynamicPaths: 64isTerminal: trueelemType: String-`+`, bodyV2Column)got := plansToYAML(t, key.JSONPlan)require.YAMLEq(t, expectedYAML, got)diff --git a/pkg/types/telemetrytypes/telemetrytypestest/metadata_store.go b/pkg/types/telemetrytypes/telemetrytypestest/metadata_store.goindex c962933029..fca5e80608 100644--- a/pkg/types/telemetrytypes/telemetrytypestest/metadata_store.go+++ b/pkg/types/telemetrytypes/telemetrytypestest/metadata_store.go@@ -20,9 +20,11 @@ type MockMetadataStore struct {PromotedPathsMap map[string]boolLogsJSONIndexesMap map[string][]schemamigrator.IndexLookupKeysMap map[telemetrytypes.MetricMetadataLookupKey]int64+ // StaticFields holds signal-specific intrinsic field definitions (e.g. telemetrylogs.IntrinsicFields).+ StaticFields map[string]telemetrytypes.TelemetryFieldKey}-// NewMockMetadataStore creates a new instance of MockMetadataStore with initialized maps+// NewMockMetadataStore creates a new instance of MockMetadataStore with initialized maps.func NewMockMetadataStore() *MockMetadataStore {return &MockMetadataStore{KeysMap: make(map[string][]*telemetrytypes.TelemetryFieldKey),@@ -33,12 +35,20 @@ func NewMockMetadataStore() *MockMetadataStore {PromotedPathsMap: make(map[string]bool),LogsJSONIndexesMap: make(map[string][]schemamigrator.Index),LookupKeysMap: make(map[telemetrytypes.MetricMetadataLookupKey]int64),+ StaticFields: make(map[string]telemetrytypes.TelemetryFieldKey),}}+// SetStaticFields sets the static fields for the mock metadata store.+// Pass the signal-specific intrinsic fields (e.g. telemetrylogs.IntrinsicFields) so the mock+// mirrors what the real metadata store does when injecting those definitions into key results.+func (m *MockMetadataStore) SetStaticFields(intrinsicFields map[string]telemetrytypes.TelemetryFieldKey) {+ m.StaticFields = intrinsicFields+}+// GetKeys returns a map of field keys types.TelemetryFieldKey by namefunc (m *MockMetadataStore) GetKeys(ctx context.Context, fieldKeySelector *telemetrytypes.FieldKeySelector) (map[string][]*telemetrytypes.TelemetryFieldKey, bool, error) {-+ setOfKeys := make(map[string]*telemetrytypes.TelemetryFieldKey)result := make(map[string][]*telemetrytypes.TelemetryFieldKey)// If selector is nil, return all keys@@ -46,18 +56,30 @@ func (m *MockMetadataStore) GetKeys(ctx context.Context, fieldKeySelector *telemreturn m.KeysMap, true, nil}- // Apply selector logic+ // Apply selector logic from KeysMapfor name, keys := range m.KeysMap {- // Check if name matchesif matchesName(fieldKeySelector, name) {- filteredKeys := []*telemetrytypes.TelemetryFieldKey{}for _, key := range keys {if matchesKey(fieldKeySelector, key) {- filteredKeys = append(filteredKeys, key)+ if _, exists := setOfKeys[key.Text()]; !exists {+ result[name] = append(result[name], key)+ setOfKeys[key.Text()] = key+ }}}- if len(filteredKeys) > 0 {- result[name] = filteredKeys+ }+ }++ // StaticFields (e.g. IntrinsicFields), mirroring the real metadata store.+ for key, field := range m.StaticFields {+ if !matchesName(fieldKeySelector, key) {+ continue+ }++ if matchesKey(fieldKeySelector, &field) {+ if _, exists := setOfKeys[field.Text()]; !exists {+ result[field.Name] = append(result[field.Name], &field)+ setOfKeys[field.Text()] = &field}}}@@ -108,7 +130,7 @@ func (m *MockMetadataStore) GetKey(ctx context.Context, fieldKeySelector *telemeresult := []*telemetrytypes.TelemetryFieldKey{}- // Find keys matching the selector+ // Find keys matching the selector from KeysMapfor name, keys := range m.KeysMap {if matchesName(fieldKeySelector, name) {for _, key := range keys {@@ -119,6 +141,17 @@ func (m *MockMetadataStore) GetKey(ctx context.Context, fieldKeySelector *teleme}}+ // Add matching StaticFields (e.g. IntrinsicFields), same as the real metadata store does+ for key, field := range m.StaticFields {+ if !matchesName(fieldKeySelector, key) {+ continue+ }++ if matchesKey(fieldKeySelector, &field) {+ result = append(result, &field)+ }+ }+return result, nil}