Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Add default $ps & $timestamp env for scan expr #343

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion states/scan_binlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func (s *InstanceState) ScanBinlogCommand(ctx context.Context, p *ScanBinlogPara

err = s.scanBinlogs(pkObject, fieldObjects, func(pk storage.PrimaryKey, offset int, values map[int64]any) error {
pkv := pk.GetValue()
ts := values[1].(int64)
if !p.IgnoreDelete {
ts := values[1].(int64)
if deletedRecords[pkv] > uint64(ts) {
return nil
}
Expand All @@ -188,6 +188,8 @@ func (s *InstanceState) ScanBinlogCommand(ctx context.Context, p *ScanBinlogPara
env := lo.MapKeys(values, func(_ any, fid int64) string {
return fields[fid].Name
})
env["$pk"] = pkv
env["$timestamp"] = ts
program, err := expr.Compile(p.Expr, expr.Env(env))
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions states/scan_deltalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func (s *InstanceState) ScanDeltalogCommand(ctx context.Context, p *ScanDeltalog
}()
if len(p.Expr) != 0 {
env := map[string]any{
"pk": pk.GetValue(),
"ts": ts,
"$pk": pk.GetValue(),
"$timestamp": ts,
}
program, err := expr.Compile(p.Expr, expr.Env(env))
if err != nil {
Expand Down
Loading