diff --git a/quesma/ingest/processor.go b/quesma/ingest/processor.go index c9183671b..0949bfc36 100644 --- a/quesma/ingest/processor.go +++ b/quesma/ingest/processor.go @@ -934,7 +934,7 @@ func NewIngestProcessor(cfg *config.QuesmaConfiguration, chDb *sql.DB, phoneHome func NewOnlySchemaFieldsCHConfig() *chLib.ChTableConfig { return &chLib.ChTableConfig{ - HasTimestamp: false, + HasTimestamp: true, TimestampDefaultsNow: true, Engine: "MergeTree", OrderBy: "(" + `"@timestamp"` + ")", @@ -944,13 +944,12 @@ func NewOnlySchemaFieldsCHConfig() *chLib.ChTableConfig { Attributes: []chLib.Attribute{chLib.NewDefaultStringAttribute()}, CastUnsupportedAttrValueTypesToString: false, PreferCastingToOthers: false, - Settings: "allow_nullable_key=true", } } func NewDefaultCHConfig() *chLib.ChTableConfig { return &chLib.ChTableConfig{ - HasTimestamp: false, + HasTimestamp: true, TimestampDefaultsNow: true, Engine: "MergeTree", OrderBy: "(" + `"@timestamp"` + ")", @@ -965,7 +964,6 @@ func NewDefaultCHConfig() *chLib.ChTableConfig { }, CastUnsupportedAttrValueTypesToString: true, PreferCastingToOthers: true, - Settings: "allow_nullable_key=true", } } @@ -978,7 +976,6 @@ func NewChTableConfigNoAttrs() *chLib.ChTableConfig { Attributes: []chLib.Attribute{}, CastUnsupportedAttrValueTypesToString: true, PreferCastingToOthers: true, - Settings: "allow_nullable_key=true", } } @@ -996,6 +993,5 @@ func NewChTableConfigFourAttrs() *chLib.ChTableConfig { }, CastUnsupportedAttrValueTypesToString: true, PreferCastingToOthers: true, - Settings: "allow_nullable_key=true", } } diff --git a/quesma/model/base_visitor.go b/quesma/model/base_visitor.go index 6d3000141..88b2cede6 100644 --- a/quesma/model/base_visitor.go +++ b/quesma/model/base_visitor.go @@ -49,7 +49,7 @@ func (v *BaseExprVisitor) VisitTuple(t TupleExpr) interface{} { if v.OverrideVisitTuple != nil { return v.OverrideVisitTuple(v, t) } - return NewTupleExpr(v.VisitChildren(t.Exprs)) + return NewTupleExpr(v.VisitChildren(t.Exprs)...) } func (v *BaseExprVisitor) VisitInfix(e InfixExpr) interface{} { diff --git a/quesma/quesma/schema_search_after_transformer.go b/quesma/quesma/schema_search_after_transformer.go index 0c9a3c05d..5effccbe0 100644 --- a/quesma/quesma/schema_search_after_transformer.go +++ b/quesma/quesma/schema_search_after_transformer.go @@ -178,8 +178,8 @@ func (s searchAfterStrategyBasicAndFast) transform(query *model.Query, searchAft // But because some fields might be ASC, we need to swap those values in the tuple. fmt.Println("searchAfterParsed", searchAfterParsed) tupleLen := len(searchAfterParsed) - lhs := model.NewTupleExpr(make([]model.Expr, tupleLen)) - rhs := model.NewTupleExpr(make([]model.Expr, tupleLen)) + lhs := model.NewTupleExpr(make([]model.Expr, tupleLen)...) + rhs := model.NewTupleExpr(make([]model.Expr, tupleLen)...) for i, searchAfterValue := range searchAfterParsed { lhs.Exprs[i] = searchAfterValue rhs.Exprs[i] = query.SelectCommand.OrderBy[i].Expr diff --git a/quesma/quesma/search_test.go b/quesma/quesma/search_test.go index ec0cd363f..d9b3b4de4 100644 --- a/quesma/quesma/search_test.go +++ b/quesma/quesma/search_test.go @@ -1345,7 +1345,7 @@ func TestSearchAfterParameter_sortByMultipleFields(t *testing.T) { }, { request: `{"search_after": [1706551896491, "m3", 3], "size": 3, "track_total_hits": false, "sort": [{"@timestamp": {"order": "desc"}}, {"message": {"order": "asc"}}, {"bicep_size": {"order": "desc"}}]}`, - expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE (fromUnixTimestamp64Milli(1706551896491), "message", 3)>("@timestamp", 'm3', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, + expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE tuple(fromUnixTimestamp64Milli(1706551896491), "message", 3)>tuple("@timestamp", 'm3', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, resultRowsFromDB: [][]any{ {someTime, int64(4), "m4"}, {someTime, int64(5), "m5"}, @@ -1359,7 +1359,7 @@ func TestSearchAfterParameter_sortByMultipleFields(t *testing.T) { }, { request: `{"search_after": [1706551896491, "m5", 0], "size": 3, "track_total_hits": false, "sort": [{"@timestamp": {"order": "desc"}}, {"message": {"order": "asc"}}, {"bicep_size": {"order": "desc"}}]}`, - expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE (fromUnixTimestamp64Milli(1706551896491), "message", 0)>("@timestamp", 'm5', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, + expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE tuple(fromUnixTimestamp64Milli(1706551896491), "message", 0)>tuple("@timestamp", 'm5', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, resultRowsFromDB: [][]any{ {sub(1), int64(0), "m6"}, {sub(1), int64(0), "m7"}, @@ -1373,7 +1373,7 @@ func TestSearchAfterParameter_sortByMultipleFields(t *testing.T) { }, { request: `{"search_after": [1706551896491, "m8", 0], "size": 3, "track_total_hits": false, "sort": [{"@timestamp": {"order": "desc"}}, {"message": {"order": "asc"}}, {"bicep_size": {"order": "desc"}}]}`, - expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE (fromUnixTimestamp64Milli(1706551896491), "message", 0)>("@timestamp", 'm8', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, + expectedSQL: `SELECT "@timestamp", "bicep_size", "message" FROM __quesma_table_name WHERE tuple(fromUnixTimestamp64Milli(1706551896491), "message", 0)>tuple("@timestamp", 'm8', "bicep_size") ORDER BY "@timestamp" DESC, "message" ASC, "bicep_size" DESC LIMIT 3`, resultRowsFromDB: [][]any{ {sub(1), int64(0), "m9"}, {sub(2), int64(0), "m10"},