-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: return error when doing ResolveIndices
#8929
Conversation
/run-all-tests |
/run-all-tests |
/run-all-tests |
/run-all-tests |
/run-all-tests |
ResolveIndices
ResolveIndices
expression/column.go
Outdated
col.Index = schema.ColumnIndex(col) | ||
if col.Index == -1 { | ||
log.Errorf("Can't find column %s in schema %s", col, schema) | ||
return errors.Trace(errors.Errorf("Can't find column %s in schema %s", col, schema)) |
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.
remove errors.Trace?
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.
Errorf won't add StackTree
automatically.
And error stack is helpful for this kind of error.
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.
errors.Trace()
will be removed in the near future. It's better to generate an error with stack and remove the errors.Trace()
function call.
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.
errors.ErrorfWithStack(format string, args ...interface{})
?
pingcap/errors
have a method named WithStack(err)
which i think it's the same thing with errors.Trace
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.
After reading the implementation of errors.Errorf()
, I think the generated error already has a stack:
103 // Errorf formats according to a format specifier and returns the string
104 // as a value that satisfies error.
105 // Errorf also records the stack trace at the point it was called.
106 func Errorf(format string, args ...interface{}) error {
107 return &fundamental{
108 msg: fmt.Sprintf(format, args...),
109 stack: callers(),
110 }
111 }
I think you can directly call errors.Errorf()
to generate an error with stack trace.
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.
Oh, you're right. Changed
expression/column.go
Outdated
col.Index = schema.ColumnIndex(col) | ||
if col.Index == -1 { | ||
log.Errorf("Can't find column %s in schema %s", col, schema) | ||
return errors.Trace(errors.Errorf("Can't find column %s in schema %s", col, schema)) |
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.
errors.Trace()
will be removed in the near future. It's better to generate an error with stack and remove the errors.Trace()
function call.
ed57e85
to
965bb26
Compare
Codecov Report
@@ Coverage Diff @@
## master #8929 +/- ##
==========================================
- Coverage 67.25% 67.17% -0.08%
==========================================
Files 371 371
Lines 76223 76393 +170
==========================================
+ Hits 51261 51318 +57
- Misses 20424 20490 +66
- Partials 4538 4585 +47
Continue to review full report at Codecov.
|
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
What problem does this PR solve?
Originally, there're some cases that
ResolveIndices
find out that there're some columns not resolved although the SQL can be executed successfully.This pr fixes it and let
ResolveIndices
return error.What is changed and how it works?
Fix the following cases:
columnPruning
doesn't prune the_rowid
column correctly_rowid
column returned and changed the schema of operators above the DataSource operator.And changed the
ResolveIndices
method let it return an error.Check List
Tests
Code changes
Side effects
Related changes
None
This change is