-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat(type): add support for type PrecisionTimestamp and PrecisionTimestampTz #41
feat(type): add support for type PrecisionTimestamp and PrecisionTimestampTz #41
Conversation
anshuldata
commented
Aug 7, 2024
- Introduced type "PrecisionTimeStampType" and "PrecisionTimeStampTzType" which implements Type interface
- Support for Literal expression using PrecisionTimestamp and PrecisionTimestampTz
- Fixed "ProtoLiteral" ToProtoLiteral API to switch on type instead of value. Felt this is cleaner and extensible since converting based on type. Used "ProtoLiteral" to create Literal interface for PrecisionTimestamp and PrecisionTimestampTz
…stampTz * Support for Literal expression using these types
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #41 +/- ##
==========================================
+ Coverage 46.38% 47.31% +0.92%
==========================================
Files 15 16 +1
Lines 5553 5664 +111
==========================================
+ Hits 2576 2680 +104
- Misses 2809 2812 +3
- Partials 168 172 +4 ☔ View full report in Codecov by Sentry. |
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.
It looks like a bunch of the code you introduced doesn't have test cases
Can you resolve that as well as the other comments? We should at least have test cases for the production paths (even if we don't for things like String() and weird error conditions)
go.mod
Outdated
@@ -6,23 +6,29 @@ go 1.20 | |||
|
|||
require ( | |||
github.com/alecthomas/participle/v2 v2.0.0 | |||
github.com/cockroachdb/errors v1.11.3 |
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.
i don't think it makes sense to source the cockroachdb errors package for a test. Let's revert the go.mod/go.sum changes.
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.
This is a utility library which has useful function to construct meaningful error. So good to keep it
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.
how is it different than just using fmt.Errorf
instead? I agree with @jacques-n that I don't see the benefit in the cockroachdb errors package. What functionality is it providing that we can't already get from errors.New
and fmt.Errorf
?
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.
I felt instead of using some methods from fmt and some from standard "errors". It is good to use one library. This cockroach library has much richer APIs (e.g. adding Hint to errors) too. Hence I used it so that we can use a single lib for errors and augment errors to be more informative
Though, for this task I could use existing fmt.Errorf. So I reverted back to fmt instead of using cockroach/errors. I still feel this API will be useful to report more meaningful error. I will reintroduce in future when I use APIs of this lib which aren't available in standard package
32156e3
to
ad153da
Compare
Added unit tests for below parts
I found a bug too in my code because of above. Thanks |
We will add tests for other types (existing ones) as part of #33 |
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.
A few nitpicks
@@ -7,13 +7,13 @@ package expr | |||
import ( | |||
"bytes" | |||
"fmt" | |||
"google.golang.org/protobuf/types/known/anypb" |
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.
why did this import move? Can we please put it back in the import list with the rest of the imports that are not stdlib imports?
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.
as elsewhere, -1 on review comments around import order. If we want a specific order, add as precommit tests.
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.
yes, it should be fixed by pre-commit. I will add a pre-commit action to detect imports in future PR
go.mod
Outdated
@@ -6,23 +6,29 @@ go 1.20 | |||
|
|||
require ( | |||
github.com/alecthomas/participle/v2 v2.0.0 | |||
github.com/cockroachdb/errors v1.11.3 |
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.
how is it different than just using fmt.Errorf
instead? I agree with @jacques-n that I don't see the benefit in the cockroachdb errors package. What functionality is it providing that we can't already get from errors.New
and fmt.Errorf
?
@@ -7,13 +7,13 @@ package expr | |||
import ( | |||
"bytes" | |||
"fmt" | |||
"google.golang.org/protobuf/types/known/anypb" |
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.
as elsewhere, -1 on review comments around import order. If we want a specific order, add as precommit tests.
Note that your patch only appears to have 34% code coverage. We should strive for patches to meet or exceed existing coverage. |
3a9d814
to
e24f72b
Compare
Fixed it by adding more tests which covers code which was missing coverage. |
e24f72b
to
799211f
Compare
Replied in this comment |
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.
Just a few other nitpicks, everything else looks good to me besides agreeing with @jacques-n that we should raise the test coverage
I did fix it with last commit and now coverage for type change is around 97%. |
Can you merge this @zeroshade ? I don't have write permission Thanks |
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.
Looks good. Test coverage is well above codebase. Thanks @anshuldata