Skip to content

Commit

Permalink
Should be +- all, need cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed Dec 26, 2024
1 parent fa2b697 commit 22ed55b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
8 changes: 2 additions & 6 deletions quesma/ingest/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"` + ")",
Expand All @@ -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"` + ")",
Expand All @@ -965,7 +964,6 @@ func NewDefaultCHConfig() *chLib.ChTableConfig {
},
CastUnsupportedAttrValueTypesToString: true,
PreferCastingToOthers: true,
Settings: "allow_nullable_key=true",
}
}

Expand All @@ -978,7 +976,6 @@ func NewChTableConfigNoAttrs() *chLib.ChTableConfig {
Attributes: []chLib.Attribute{},
CastUnsupportedAttrValueTypesToString: true,
PreferCastingToOthers: true,
Settings: "allow_nullable_key=true",
}
}

Expand All @@ -996,6 +993,5 @@ func NewChTableConfigFourAttrs() *chLib.ChTableConfig {
},
CastUnsupportedAttrValueTypesToString: true,
PreferCastingToOthers: true,
Settings: "allow_nullable_key=true",
}
}
2 changes: 1 addition & 1 deletion quesma/model/base_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down
4 changes: 2 additions & 2 deletions quesma/quesma/schema_search_after_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions quesma/quesma/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand All @@ -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"},
Expand All @@ -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"},
Expand Down

0 comments on commit 22ed55b

Please sign in to comment.