-
Notifications
You must be signed in to change notification settings - Fork 6k
expression: add ctx
to expression.Eval
#48609
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
Conversation
0dc4c5d
to
e4ae0f0
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #48609 +/- ##
================================================
+ Coverage 71.0843% 72.9651% +1.8808%
================================================
Files 1365 1389 +24
Lines 404348 413600 +9252
================================================
+ Hits 287428 301784 +14356
+ Misses 96936 93022 -3914
+ Partials 19984 18794 -1190
Flags with carried forward coverage won't be shown. Click here to find out more.
|
/retest |
/test tiprow_fast_test |
@lcwangchao: The specified target(s) for
The following commands are available to trigger optional jobs:
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test tiprow_fast_test |
@lcwangchao: The specified target(s) for
The following commands are available to trigger optional jobs:
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
func (c *Constant) EvalWithInnerCtx(row chunk.Row) (types.Datum, error) { | ||
var ctx sessionctx.Context | ||
if c.DeferredExpr != nil { | ||
if sf, sfOk := c.DeferredExpr.(*ScalarFunction); sfOk { | ||
ctx = sf.GetCtx() | ||
} | ||
} | ||
return c.Eval(ctx, row) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvalWithInnerCtx
will use the the context in the ScalarFunction
as the input parameter for Eval
. If c.DefferedExpr
is nil, the ctx will also be nil, don't worry because ctx
will not be used in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvalWithInnerCtx
will be removed after we replaces all EvalWithInnerCtx
with Eval
in the later PRs
intest.AssertNotNil(ctx) | ||
if dt.Kind() != types.KindMysqlDecimal { | ||
val, err := dt.ConvertTo(sf.GetCtx().GetSessionVars().StmtCtx.TypeCtx(), c.RetType) | ||
val, err := dt.ConvertTo(ctx.GetSessionVars().StmtCtx.TypeCtx(), c.RetType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll use the input ctx instead of the inner one after this PR
if sc := ctx.GetSessionVars().StmtCtx; sc != nil { | ||
err = sc.HandleTruncate(err) | ||
} | ||
if sc := ctx.GetSessionVars().StmtCtx; sc != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll use the ctx from parameter to replace the inner ctx
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lance6716, tiancaiamao, XuHuaiyu, YangKeao, zimulala The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
@lcwangchao: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: close #48608
What is changed and how it works?
ctx
toexpression.Eval
ctx
in the places callingEval
, just use it as the first paramterexpression.EvalWithInnerCtx
to replace theEval
when we cannot not find a valid ctx.expression.EvalWithInnerCtx
is deprecated and we should remove it in the later PRs.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.