Skip to content

Commit

Permalink
Update test expected results + make 1 test trickier
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed Dec 28, 2024
1 parent 3f506cd commit 4c67fb5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
16 changes: 0 additions & 16 deletions quesma/model/expr_string_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,6 @@ func (v *renderer) VisitLiteral(l LiteralExpr) interface{} {
}
}

func (v *renderer) VisitTuple(t TupleExpr) interface{} {
switch len(t.Exprs) {
case 0:
logger.WarnWithThrottling("VisitTuple", "TupleExpr with no expressions")
return "()"
case 1:
return t.Exprs[0].Accept(v)
default:
args := make([]string, len(t.Exprs))
for i, arg := range t.Exprs {
args[i] = arg.Accept(v).(string)
}
return fmt.Sprintf("(%s)", strings.Join(args, ","))
}
}

func (v *renderer) VisitTuple(t TupleExpr) interface{} {
switch len(t.Exprs) {
case 0:
Expand Down
7 changes: 3 additions & 4 deletions quesma/testdata/aggregation_requests_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -4691,15 +4691,14 @@ var AggregationTests2 = []AggregationTestCase{
},
{ // [70]
TestName: "simplest terms with exclude (array of values)",
// TODO add ' somewhere in exclude after the merge!
QueryRequestJson: `
{
"aggs": {
"1": {
"terms": {
"field": "chess_goat",
"size": 2,
"exclude": ["Carlsen", "Kasparov", "Fis._er*"]
"exclude": ["Carlsen", "Kasparov", "Fis._er'*"]
}
}
},
Expand Down Expand Up @@ -4740,10 +4739,10 @@ var AggregationTests2 = []AggregationTestCase{
},
ExpectedPancakeSQL: `
SELECT sum(count(*)) OVER () AS "aggr__1__parent_count",
if("chess_goat" NOT IN tuple('Carlsen', 'Kasparov', 'Fis._er*'), "chess_goat", NULL)
if("chess_goat" NOT IN tuple('Carlsen', 'Kasparov', 'Fis._er\'*'), "chess_goat", NULL)
AS "aggr__1__key_0", count(*) AS "aggr__1__count"
FROM __quesma_table_name
GROUP BY if("chess_goat" NOT IN tuple('Carlsen', 'Kasparov', 'Fis._er*'), "chess_goat", NULL) AS "aggr__1__key_0"
GROUP BY if("chess_goat" NOT IN tuple('Carlsen', 'Kasparov', 'Fis._er\'*'), "chess_goat", NULL) AS "aggr__1__key_0"
ORDER BY "aggr__1__count" DESC, "aggr__1__key_0" ASC
LIMIT 3`,
},
Expand Down
8 changes: 4 additions & 4 deletions quesma/testdata/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1014,10 +1014,10 @@ var TestsSearch = []SearchTestCase{
},
"track_total_hits": true
}`,
[]string{`("type"='task' AND "task.enabled" IN (true,54,'abc','abc\'s'))`},
[]string{`("type"='task' AND "task.enabled" IN tuple(true, 54, 'abc', 'abc\'s'))`},
model.ListAllFields,
[]string{
`SELECT "message" FROM ` + TableName + ` WHERE ("type"='task' AND "task.enabled" IN (true,54,'abc','abc\\'s')) LIMIT 10`,
`SELECT "message" FROM ` + TableName + ` WHERE ("type"='task' AND "task.enabled" IN tuple(true, 54, 'abc', 'abc\\'s')) LIMIT 10`,
`SELECT count(*) AS "column_0" FROM ` + TableName,
},
[]string{},
Expand Down Expand Up @@ -2196,13 +2196,13 @@ var TestsSearch = []SearchTestCase{
},
"track_total_hits": false
}`,
[]string{`("cliIP" IN ('2601:204:c503:c240:9c41:5531:ad94:4d90','50.116.43.98','75.246.0.64') AND ("@timestamp">=fromUnixTimestamp64Milli(1715817600000) AND "@timestamp"<=fromUnixTimestamp64Milli(1715990399000)))`},
[]string{`("cliIP" IN tuple('2601:204:c503:c240:9c41:5531:ad94:4d90', '50.116.43.98', '75.246.0.64') AND ("@timestamp">=fromUnixTimestamp64Milli(1715817600000) AND "@timestamp"<=fromUnixTimestamp64Milli(1715990399000)))`},
model.ListAllFields,
//[]model.Query{withLimit(justSimplestWhere(`("cliIP" IN ('2601:204:c503:c240:9c41:5531:ad94:4d90','50.116.43.98','75.246.0.64') AND ("@timestamp">=parseDateTime64BestEffort('2024-05-16T00:00:00') AND "@timestamp"<=parseDateTime64BestEffort('2024-05-17T23:59:59')))`), 1)},
[]string{
`SELECT "message" ` +
`FROM ` + TableName + ` ` +
`WHERE ("cliIP" IN ('2601:204:c503:c240:9c41:5531:ad94:4d90','50.116.43.98','75.246.0.64') ` +
`WHERE ("cliIP" IN tuple('2601:204:c503:c240:9c41:5531:ad94:4d90', '50.116.43.98', '75.246.0.64') ` +
`AND ("@timestamp">=fromUnixTimestamp64Milli(1715817600000) AND "@timestamp"<=fromUnixTimestamp64Milli(1715990399000))) ` +
`LIMIT 1`,
},
Expand Down

0 comments on commit 4c67fb5

Please sign in to comment.