Skip to content

Commit

Permalink
Remove quesma/kibana (#1025)
Browse files Browse the repository at this point in the history
I noticed this module depends on `quesma/clickhouse`, which stroke me as
little odd when I realized that this is just one util function and part
of parsing (specifically date parsing) which naturally belongs there.

Related: #1017
  • Loading branch information
mieciu authored Nov 21, 2024
1 parent f7233ef commit 642dee3
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
5 changes: 2 additions & 3 deletions quesma/model/bucket_aggregations/date_histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"context"
"fmt"
"quesma/clickhouse"
"quesma/kibana"
"quesma/logger"
"quesma/model"
"quesma/util"
Expand Down Expand Up @@ -154,7 +153,7 @@ func (query *DateHistogram) GenerateSQL() model.Expr {
}

func (query *DateHistogram) generateSQLForFixedInterval() model.Expr {
interval, err := kibana.ParseInterval(query.interval)
interval, err := util.ParseInterval(query.interval)
if err != nil {
logger.ErrorWithCtx(query.ctx).Msg(err.Error())
}
Expand Down Expand Up @@ -257,7 +256,7 @@ func (query *DateHistogram) SetMinDocCountToZero() {
}

func (query *DateHistogram) NewRowsTransformer() model.QueryRowsTransformer {
duration, err := kibana.ParseInterval(query.interval)
duration, err := util.ParseInterval(query.interval)
var differenceBetweenTwoNextKeys int64
if err == nil {
differenceBetweenTwoNextKeys = duration.Milliseconds()
Expand Down
3 changes: 2 additions & 1 deletion quesma/kibana/dates.go → quesma/queryparser/dates.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0
package kibana

package queryparser

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0
package kibana

package queryparser

import (
"context"
Expand Down
3 changes: 1 addition & 2 deletions quesma/queryparser/pancake_aggregation_parser_buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package queryparser
import (
"fmt"
"quesma/clickhouse"
"quesma/kibana"
"quesma/logger"
"quesma/model"
"quesma/model/bucket_aggregations"
Expand Down Expand Up @@ -82,7 +81,7 @@ func (cw *ClickhouseQueryTranslator) pancakeTryBucketAggregation(aggregation *pa
weAddedMissing := false
if missingRaw, exists := dateHistogram["missing"]; exists {
if missing, ok := missingRaw.(string); ok {
dateManager := kibana.NewDateManager(cw.Ctx)
dateManager := NewDateManager(cw.Ctx)
if missingExpr, parsingOk := dateManager.ParseDateUsualFormat(missing, dateTimeType); parsingOk {
field = model.NewFunction("COALESCE", field, missingExpr)
weAddedMissing = true
Expand Down
4 changes: 2 additions & 2 deletions quesma/queryparser/query_parser.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0

package queryparser

import (
Expand All @@ -9,7 +10,6 @@ import (
"fmt"
"github.com/k0kubun/pp"
"quesma/clickhouse"
"quesma/kibana"
"quesma/logger"
"quesma/model"
"quesma/model/bucket_aggregations"
Expand Down Expand Up @@ -804,7 +804,7 @@ func (cw *ClickhouseQueryTranslator) parseRange(queryMap QueryMap) model.SimpleQ
valueRaw := v.(QueryMap)[op]
value := sprint(valueRaw)
defaultValue := model.NewLiteral(value)
dateManager := kibana.NewDateManager(cw.Ctx)
dateManager := NewDateManager(cw.Ctx)

// Three stages:
// 1. dateManager.ParseDateUsualFormat
Expand Down
2 changes: 1 addition & 1 deletion quesma/kibana/intervals.go → quesma/util/intervals.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0
package kibana
package util

import (
"strconv"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Quesma, licensed under the Elastic License 2.0.
// SPDX-License-Identifier: Elastic-2.0
package kibana
package util

import (
"github.com/stretchr/testify/assert"
Expand Down

0 comments on commit 642dee3

Please sign in to comment.