Skip to content

Commit

Permalink
Facets fix (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski authored May 15, 2024
1 parent 7e1372f commit 65f8591
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 6 additions & 1 deletion quesma/clickhouse/quesma_communicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ func (lm *LogManager) ProcessQuery(ctx context.Context, table *Table, query *mod
}
colNames, err := table.extractColumns(query, false)
sort.Strings(colNames)
sort.Strings(columns)
if columns == nil {
columns = lm.GetAllColumns(table, query)
// We should sort only if columns are not provided
// Caller is responsible for providing columns in the right order
sort.Strings(columns)
}
rowToScan := make([]interface{}, len(colNames)+len(query.NonSchemaFields))
if err != nil {
return nil, err
Expand Down
9 changes: 4 additions & 5 deletions quesma/quesma/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ func (q *QueryRunner) handleSearchCommon(ctx context.Context, indexPattern strin
fieldName = "*"
}
listQuery := queryTranslator.BuildNRowsQuery(fieldName, simpleQuery, queryInfo.Size)
hitsFallback, err = q.logManager.ProcessQuery(ctx, table, listQuery, q.logManager.GetAllColumns(table, listQuery))
hitsFallback, err = q.logManager.ProcessQuery(ctx, table, listQuery, nil)
if err != nil {
logger.ErrorWithCtx(ctx).Msgf("error processing fallback query. Err: %v, query: %+v", err, listQuery)
pushSecondaryInfo(q.quesmaManagementConsole, id, path, body, translatedQueryBody, responseBody, startTime)
return responseBody, err
}
countQuery := queryTranslator.BuildSimpleCountQuery(simpleQuery.Sql.Stmt)
countResult, err := q.logManager.ProcessQuery(ctx, table, countQuery, q.logManager.GetAllColumns(table, countQuery))
countResult, err := q.logManager.ProcessQuery(ctx, table, countQuery, nil)
if err != nil {
logger.ErrorWithCtx(ctx).Msgf("error processing count query. Err: %v, query: %+v", err, countQuery)
pushSecondaryInfo(q.quesmaManagementConsole, id, path, body, translatedQueryBody, responseBody, startTime)
Expand Down Expand Up @@ -477,10 +477,8 @@ func (q *QueryRunner) makeBasicQuery(ctx context.Context,
case model.ListAllFields:
// queryInfo = (ListAllFields, "*", 0, LIMIT)
fullQuery = queryTranslator.BuildNRowsQuery("*", simpleQuery, queryInfo.I2)
columns = q.logManager.GetAllColumns(table, fullQuery)
case model.Normal:
fullQuery = queryTranslator.BuildSimpleSelectQuery(simpleQuery.Sql.Stmt, queryInfo.I2)
columns = q.logManager.GetAllColumns(table, fullQuery)
}
return fullQuery, columns
}
Expand All @@ -502,6 +500,7 @@ func (q *QueryRunner) searchWorkerCommon(ctx context.Context, fullQuery model.Qu
} else {
dbQueryCtx = ctx
}

hits, err = q.logManager.ProcessQuery(dbQueryCtx, table, &fullQuery, columns)
translatedQueryBody = []byte(fullQuery.String())
if err != nil {
Expand Down Expand Up @@ -581,7 +580,7 @@ func (q *QueryRunner) searchAggregationWorkerCommon(ctx context.Context, aggrega
logger.InfoWithCtx(ctx).Msgf("SQL: %s", agg.String())
sqls += agg.Query.String() + "\n"
}
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &agg.Query, q.logManager.GetAllColumns(table, &agg.Query))
rows, err := q.logManager.ProcessQuery(dbQueryCtx, table, &agg.Query, nil)
if err != nil {
logger.ErrorWithCtx(ctx).Msg(err.Error())
continue
Expand Down

0 comments on commit 65f8591

Please sign in to comment.