MCPcopy Create free account
hub / github.com/deepflowio/deepflow / QueryWithSql

Method QueryWithSql

server/querier/engine/clickhouse/clickhouse.go:1004–1044  ·  view source on GitHub ↗
(sql string, args *common.QuerierParams)

Source from the content-addressed store, hash-verified

1002}
1003
1004func (e *CHEngine) QueryWithSql(sql string, args *common.QuerierParams) (*common.Result, *client.Debug, error) {
1005 sql, callbacks, columnSchemaMap, err := e.ParseWithSql(sql)
1006 if err != nil {
1007 log.Error(err)
1008 return nil, nil, err
1009 }
1010 if sql == "" {
1011 return nil, nil, nil
1012 }
1013
1014 query_uuid := args.QueryUUID
1015 debug := &client.Debug{
1016 IP: config.Cfg.Clickhouse.Host,
1017 QueryUUID: query_uuid,
1018 }
1019 debug.Sql = sql
1020 chClient := client.Client{
1021 Host: config.Cfg.Clickhouse.Host,
1022 Port: config.Cfg.Clickhouse.Port,
1023 UserName: config.Cfg.Clickhouse.User,
1024 Password: config.Cfg.Clickhouse.Password,
1025 DB: e.DB,
1026 Debug: debug,
1027 Context: e.Context,
1028 }
1029 params := &client.QueryParams{
1030 Sql: sql,
1031 UseQueryCache: args.UseQueryCache,
1032 QueryCacheTTL: args.QueryCacheTTL,
1033 Callbacks: callbacks,
1034 QueryUUID: query_uuid,
1035 ColumnSchemaMap: columnSchemaMap,
1036 ORGID: args.ORGID,
1037 }
1038 rst, err := chClient.DoQuery(params)
1039 if err != nil {
1040 log.Error(err)
1041 return nil, debug, err
1042 }
1043 return rst, debug, err
1044}
1045
1046func (e *CHEngine) ParseWithSql(sql string) (string, map[string]func(*common.Result) error, map[string]*common.ColumnSchema, error) {
1047 checks := checkWithSqlRegexp.FindAllStringSubmatch(sql, -1)

Callers 1

ExecuteQueryMethod · 0.95

Calls 3

ParseWithSqlMethod · 0.95
DoQueryMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected