Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 88a9941

Browse files
author
trzysiek
committed
Cleanup
1 parent 49fb4c8 commit 88a9941

File tree

8 files changed

+17
-40
lines changed

8 files changed

+17
-40
lines changed

platform/frontend_connectors/search.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,7 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
623623
pushSecondaryInfo(q.debugInfoCollector, id, "", path, bodyAsBytes, queriesBody, responseBody, startTime)
624624
return responseBody, errors.New(string(responseBody))
625625
}
626-
for _, query := range plan.Queries {
627-
fmt.Println("PRE", query.SelectCommand.String())
628-
}
629626
err = q.transformQueries(ctx, plan)
630-
for _, query := range plan.Queries {
631-
fmt.Println("POST", query.SelectCommand.String())
632-
}
633627
if err != nil {
634628
return responseBody, err
635629
}

platform/frontend_connectors/search_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,6 @@ func TestSearchTrackTotalCount(t *testing.T) {
859859
for i, tt := range testdata.FullSearchRequests {
860860
for _, handlerName := range handlers {
861861
t.Run(strconv.Itoa(i)+" "+tt.Name, func(t *testing.T) {
862-
fmt.Println("test i", i)
863-
if i != 6 {
864-
//t.Skip()
865-
}
866862
test(handlerName, tt)
867863
})
868864
}

platform/model/bucket_aggregations/dateRange.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"github.com/QuesmaOrg/quesma/platform/logger"
99
"github.com/QuesmaOrg/quesma/platform/model"
10-
"github.com/k0kubun/pp"
1110
"time"
1211
)
1312

@@ -86,7 +85,6 @@ func (query DateRange) TranslateSqlResponseToJson(rows []model.QueryResultRow) m
8685
}
8786
for intervalIdx, columnIdx := 0, startIteration; intervalIdx < len(query.intervals); intervalIdx++ {
8887
responseForInterval, nextColumnIdx := query.responseForInterval(&rows[0], intervalIdx, columnIdx)
89-
fmt.Println("responseForInterval", responseForInterval)
9088
response = append(response, responseForInterval)
9189
columnIdx = nextColumnIdx
9290
}
@@ -96,7 +94,7 @@ func (query DateRange) TranslateSqlResponseToJson(rows []model.QueryResultRow) m
9694
}
9795

9896
func (query DateRange) String() string {
99-
return "date_range, intervals: " + fmt.Sprintf("%v", query.intervals)
97+
return fmt.Sprintf("date_range, intervals: %v", query.intervals)
10098
}
10199

102100
func (query DateRange) responseForInterval(row *model.QueryResultRow, intervalIdx, columnIdx int) (
@@ -185,7 +183,6 @@ func (query DateRange) CombinatorTranslateSqlResponseToJson(subGroup CombinatorG
185183

186184
// TODO: we need translate relative to real time
187185
interval := query.intervals[subGroup.idx]
188-
pp.Println(interval, model.AsString(interval.begin), model.AsString(interval.end))
189186
if interval.begin != UnboundedInterval {
190187
response["from"] = model.AsString(interval.begin)
191188
response["from_as_string"] = interval.begin

platform/model/expr_string_renderer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ func (v *renderer) VisitFunction(e FunctionExpr) interface{} {
6767
}
6868

6969
func (v *renderer) VisitLiteral(l LiteralExpr) interface{} {
70-
fmt.Println("VisitLiteral", l)
7170
switch val := l.Value.(type) {
7271
case string:
7372
switch l.EscapeType {

platform/model/where_visitor.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,11 @@ func FindTimestampLowerBound(field ColumnRef, whereClause Expr) (lowerBoundTs ti
1919
if columnRef, ok := e.Left.(ColumnRef); ok && columnRef == field && e.Op == ">=" || e.Op == ">" {
2020
if fun, ok := e.Right.(FunctionExpr); ok && fun.Name == FromUnixTimestampMs && len(fun.Args) == 1 {
2121
if rhs, ok := fun.Args[0].(LiteralExpr); ok {
22-
var tim time.Time
23-
switch v := rhs.Value.(type) {
24-
case time.Time:
25-
tim = v
26-
case TimeLiteral:
27-
tim = v.Value
28-
default:
29-
return nil
30-
}
31-
32-
if !found || tim.Before(lowerBoundTs) {
33-
lowerBoundTs = tim
34-
found = true
22+
if timestamp, ok := rhs.Value.(TimeLiteral); ok {
23+
if !found || timestamp.Value.Before(lowerBoundTs) {
24+
lowerBoundTs = timestamp.Value
25+
found = true
26+
}
3527
}
3628
}
3729
}

platform/parsers/elastic_query_dsl/aggregation_date_range_parser.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (cw *ClickhouseQueryTranslator) parseDateRangeAggregation(aggregation *panc
3535
const defaultIntervalBound = bucket_aggregations.UnboundedIntervalString
3636
var intervalBegin model.Expr
3737
if from := cw.parseStringField(rangeMap, "from", defaultIntervalBound); from != defaultIntervalBound {
38-
intervalBegin, err = cw.parseDateTimeInClickhouseMathLanguage(colRef, from)
38+
intervalBegin, err = cw.parseDateTimeInClickhouseMathLanguage(from, colRef)
3939
if err != nil {
4040
return err
4141
}
@@ -44,7 +44,7 @@ func (cw *ClickhouseQueryTranslator) parseDateRangeAggregation(aggregation *panc
4444

4545
var intervalEnd model.Expr
4646
if to := cw.parseStringField(rangeMap, "to", defaultIntervalBound); to != defaultIntervalBound {
47-
intervalEnd, err = cw.parseDateTimeInClickhouseMathLanguage(colRef, to)
47+
intervalEnd, err = cw.parseDateTimeInClickhouseMathLanguage(to, colRef)
4848
if err != nil {
4949
return err
5050
}
@@ -60,12 +60,12 @@ func (cw *ClickhouseQueryTranslator) parseDateRangeAggregation(aggregation *panc
6060
// parseDateTimeInClickhouseMathLanguage parses dateTime from Clickhouse's format
6161
// It's described here: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
6262
// Maybe not 100% of it is implemented, not sure.
63-
func (cw *ClickhouseQueryTranslator) parseDateTimeInClickhouseMathLanguage(field model.ColumnRef, dateTime string) (model.Expr, error) {
63+
func (cw *ClickhouseQueryTranslator) parseDateTimeInClickhouseMathLanguage(dateTime string, field model.ColumnRef) (model.Expr, error) {
6464
// So far we've seen only either:
6565
// 1. 2024-01-01 format TODO update
6666
dateManager := NewDateManager(cw.Ctx)
67-
if funcName, expr := dateManager.ParseDateUsualFormat(dateTime, field); expr != nil {
68-
return model.NewFunction(funcName, expr), nil
67+
if parsed := dateManager.ParseDateUsualFormat(dateTime, field); parsed != nil {
68+
return parsed, nil
6969
}
7070
// 2. expressions like now() or now()-1d
7171
res, err := cw.parseDateMathExpression(dateTime, field)

platform/parsers/elastic_query_dsl/dates.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ func (dm DateManager) parseStrictDateOptionalTimeOrEpochMillis(date any) (utcTim
6464
// ParseDateUsualFormat parses date expression, which is in [strict_date_optional_time || epoch_millis] format
6565
// (https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)
6666
// It's most usual format for date in Kibana, used e.g. in Query DSL's range, or date_histogram.
67-
func (dm DateManager) ParseDateUsualFormat(exprFromRequest any, field model.ColumnRef) (funcName string, resultExpr model.Expr) {
67+
func (dm DateManager) ParseDateUsualFormat(exprFromRequest any, field model.ColumnRef) (resultExpr model.Expr) {
6868
if unixTsInMs, success := dm.parseStrictDateOptionalTimeOrEpochMillis(exprFromRequest); success {
69-
return model.FromUnixTimestampMs, model.NewTimeLiteral(unixTsInMs, field)
69+
return model.NewFunction(model.FromUnixTimestampMs, model.NewTimeLiteral(unixTsInMs, field))
7070
}
71-
return model.FromUnixTimestampMs, nil // todo usunac te funkcje jak zawsze zwracam to samo? xD
71+
return nil
7272

7373
/*
7474
if utcTs, success := dm.parseStrictDateOptionalTimeOrEpochMillis(exprFromRequest); success {

platform/parsers/elastic_query_dsl/query_parser.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,17 +817,16 @@ func (cw *ClickhouseQueryTranslator) parseRange(queryMap QueryMap) model.SimpleQ
817817
switch fieldType {
818818
case clickhouse.DateTime, clickhouse.DateTime64:
819819
// TODO add support for "time_zone" parameter in ParseDateUsualFormat
820-
funcName, finalValue = dateManager.ParseDateUsualFormat(value, model.NewColumnRef(fieldName)) // stage 1
821-
if !areWeDoneParsing() && (op == "gte" || op == "lte" || op == "gt" || op == "lt") { // stage 2
820+
finalValue = dateManager.ParseDateUsualFormat(value, model.NewColumnRef(fieldName)) // stage 1
821+
if !areWeDoneParsing() && (op == "gte" || op == "lte" || op == "gt" || op == "lt") { // stage 2
822822
parsed, err := cw.parseDateMathExpression(value, model.NewColumnRef(fieldName))
823823
fmt.Println("QQQ parsed: ", parsed, funcName, cw.DateMathRenderer)
824824
if err == nil {
825-
funcName = "" // date math expressions don't need function name
826825
finalValue = parsed
827826
}
828827
}
829828
if !areWeDoneParsing() && isQuoted { // stage 3
830-
funcName, finalValue = dateManager.ParseDateUsualFormat(value[1:len(value)-1], model.NewColumnRef(fieldName))
829+
finalValue = dateManager.ParseDateUsualFormat(value[1:len(value)-1], model.NewColumnRef(fieldName))
831830
}
832831
case clickhouse.Invalid:
833832
if isQuoted {

0 commit comments

Comments
 (0)