Skip to content

Commit

Permalink
fix(sink): report io error when write to tdengine/sql error (#1345)
Browse files Browse the repository at this point in the history
Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
  • Loading branch information
superrxan authored Jul 29, 2022
1 parent 1cc4b5b commit 3be0095
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extensions/sinks/sql/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/lf-edge/ekuiper/extensions/sqldatabase/driver"
"github.com/lf-edge/ekuiper/pkg/api"
"github.com/lf-edge/ekuiper/pkg/cast"
"github.com/lf-edge/ekuiper/pkg/errorx"
"github.com/xo/dburl"
"reflect"
"strings"
Expand Down Expand Up @@ -109,7 +110,7 @@ func (m *sqlSink) writeToDB(ctx api.StreamContext, sqlStr *string) error {
ctx.GetLogger().Debugf(*sqlStr)
rows, err := m.db.Query(*sqlStr)
if err != nil {
return err
return fmt.Errorf("%s: %s", errorx.IOErr, err.Error())
}
return rows.Close()
}
Expand Down
3 changes: 2 additions & 1 deletion extensions/sinks/tdengine/tdengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/lf-edge/ekuiper/internal/conf"
"github.com/lf-edge/ekuiper/pkg/api"
"github.com/lf-edge/ekuiper/pkg/cast"
"github.com/lf-edge/ekuiper/pkg/errorx"
_ "github.com/taosdata/driver-go/v2/taosSql"
"reflect"
"strings"
Expand Down Expand Up @@ -268,7 +269,7 @@ func (m *taosSink) writeToDB(ctx api.StreamContext, SqlVal *string) error {
ctx.GetLogger().Debugf(finalSql)
rows, err := m.db.Query(finalSql)
if err != nil {
return err
return fmt.Errorf("%s: %s", errorx.IOErr, err.Error())
}
rows.Close()
return nil
Expand Down

0 comments on commit 3be0095

Please sign in to comment.