Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed Dec 22, 2024
1 parent 9f1b22f commit b7eb60a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
1 change: 1 addition & 0 deletions quesma/logger/log_with_throttling.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

// throttleMap: (reason name -> last logged time)
// We log only once per throttleDuration for each reason name, so that we don't spam the logs.
var throttleMap = util.SyncMap[string, time.Time]{}

const throttleDuration = 30 * time.Minute
Expand Down
6 changes: 3 additions & 3 deletions quesma/model/base_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (v *BaseExprVisitor) VisitLiteral(e LiteralExpr) interface{} {
return NewLiteral(e.Value)
}

func (v *BaseExprVisitor) VisitTuple(e TupleExpr) interface{} {
func (v *BaseExprVisitor) VisitTuple(t TupleExpr) interface{} {
if v.OverrideVisitTuple != nil {
return v.OverrideVisitTuple(v, e)
return v.OverrideVisitTuple(v, t)
}
return NewTupleExpr(v.VisitChildren(e.Exprs)...)
return NewTupleExpr(v.VisitChildren(t.Exprs)...)
}

func (v *BaseExprVisitor) VisitInfix(e InfixExpr) interface{} {
Expand Down
2 changes: 2 additions & 0 deletions quesma/queryparser/query_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,8 @@ func (cw *ClickhouseQueryTranslator) parseRegexp(queryMap QueryMap) (result mode

var funcName string
if isPatternReallySimple(pattern) {
// We'll escape this _ twice (first one here, second one in renderer, where we escape all \)
// But it's not a problem for Clickhouse! So it seems fine.
pattern = strings.ReplaceAll(pattern, "_", `\_`)
pattern = strings.ReplaceAll(pattern, ".*", "%")
pattern = strings.ReplaceAll(pattern, ".", "_")
Expand Down
3 changes: 0 additions & 3 deletions quesma/queryparser/query_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ func TestQueryParserStringAttrConfig(t *testing.T) {

for i, tt := range testdata.TestsSearch {
t.Run(fmt.Sprintf("%s(%d)", tt.Name, i), func(t *testing.T) {
if i == 37 {
t.Skip("Regexp seems to be broken because of some transformations")
}
body, parseErr := types.ParseJSON(tt.QueryJson)
assert.NoError(t, parseErr)
plan, errQuery := cw.ParseQuery(body)
Expand Down
3 changes: 0 additions & 3 deletions quesma/quesma/schema_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -958,9 +958,6 @@ func (s *SchemaCheckPass) applyMatchOperator(indexSchema schema.Schema, query *m
visitor.OverrideVisitInfix = func(b *model.BaseExprVisitor, e model.InfixExpr) interface{} {
lhs, ok := e.Left.(model.ColumnRef)
rhs, ok2 := e.Right.(model.LiteralExpr)
if e.Op == model.MatchOperator {
fmt.Println("KKKKK", e.Left, lhs, rhs, ok, ok2)
}
if ok && ok2 && e.Op == model.MatchOperator {
field, found := indexSchema.ResolveFieldByInternalName(lhs.ColumnName)
if !found {
Expand Down
2 changes: 1 addition & 1 deletion quesma/testdata/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@ var TestsSearch = []SearchTestCase{
},
"track_total_hits": false
}`,
[]string{`"field" LIKE '%\___'`},
[]string{`"field" LIKE '%\\___'`}, // escaping _ twice ("\\_") seemed wrong, but it actually works in Clickhouse!
model.ListAllFields,
[]string{
`SELECT "message" ` +
Expand Down

0 comments on commit b7eb60a

Please sign in to comment.