-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(pkg/csv2lp): add csv to line protocol conversion library #17764
Conversation
@jsteenb2 can you please help with the stakeholders to review this PR |
@sranka I'd like to see storage folks or someone who is more LP saavy give this a read. I pulled someone in from the auto assigner for the storage team. |
Hey folks, I'm looking into this today! |
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 an awesome addition to the library, thanks @sranka! There are a few things to clear up here in terms of composition and clarification. Also, I would really like to see you include a docs update similar to what you've done here. Add that as a README into this package as it would make things a lot clearer!
Also, apart from the other naming please go through an move your filenames from camelCase to snake_case, so csvTable.go
becomes csv_table.go
, etc.
Lastly, all test names should be of the format Test_ThingToTestInCamelCase
. You have a few references to the actual function you're testing under the covers, like Test_escapeMeasurement
that should become Test_EscapeMeasurement
.
Other than that, thank you again so very much for your contribution! If you have any questions I'm lurking both on the gophers.slack.com and influxcommunity.slack.com under sebito91
.
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.
Thank you @sebito91 for a detailed code review, I fixed the naming conventions of files/tests, added documentation, and overall improved the code to address your feedback. I replied to all your comments and left them up to you to mark them as resolved. Some comments/conversations are still open, I would appreciate your feedback therein.
pkg/csv2lp/csvAnnotations.go
Outdated
setupTable func(table *CsvTable, row []string) error | ||
} | ||
|
||
func (a *annotationComment) isTableAnnotation() bool { |
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.
done
pkg/csv2lp/csvAnnotations.go
Outdated
return strings.HasPrefix(strings.ToLower(comment), a.prefix) | ||
} | ||
|
||
var supportedAnnotations = []annotationComment{ |
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.
annotationComment is never updated, there is IMHO no need to have pointers herein; there are a few annotation comments (by design) that don't change
pkg/csv2lp/csvTable.go
Outdated
errors.New("no measurement supplied"), | ||
} | ||
} | ||
buffer = append(buffer, escapeMeasurement(measurement)...) |
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 also use appendConverted
fn to append field values or various data types, the appendConverted
internally uses strConv.append*
functions that accept and return []byte. A change to bytes.Buffer
would then require (on the other hand) to create temporary objects for every float, int, uint value that I don't need now. I am not sure that the situation gets better after this change. So it is trade-off situation herein. I would rather keep it the way it is.
I wish to have append
optimized by the compiler or bytes.Buffer
also accepting primitive types for writing.
pkg/csv2lp/csvTable.go
Outdated
} | ||
} | ||
} | ||
return buffer, 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.
yes, or I could simplify the function signature to use *bytes.Buffer
Excellent work @sranka, will review this and get back to you today! |
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.
Some small changes this time but we're getting closer, thanks so much for your patience @sranka !!
@@ -0,0 +1,33 @@ | |||
package csv2lp |
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.
Is this file actually used anywhere? If not we should remove...
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 is not used internally by the library. It is referenced in README.MD (Support Existing CSV files) since it helps compose a single input reader out of multiple Readers and ReadClosers.
csv2lp.MultiCloser helps with closing multiple io.Closers (files) on input, because it is not available OOTB
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.
thank you @sebito91 for review, it is now ready for the next review
@@ -0,0 +1,33 @@ | |||
package csv2lp |
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 is not used internally by the library. It is referenced in README.MD (Support Existing CSV files) since it helps compose a single input reader out of multiple Readers and ReadClosers.
csv2lp.MultiCloser helps with closing multiple io.Closers (files) on input, because it is not available OOTB
I think this build requires a |
I would appreciate any insight or explanation regarding the failing tests that are (from time to time) causing unintended interferences and testing failures. @sebito91 I rebased this branch to the latest master, it usually helps. |
That'll usually do it, but if you're importing new packages you'll need to run For example after bringing your branch down into my local repo, it looks like go.mod is missing a reference to
|
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, well done!
chore(CHANGELOG): update to include recently merged PR #17764
#17004 requests CSV support in
influx write
command, #17599 requires a separate library for CSV to line protocol conversion that shall be then used ininflux write
. This PR introduces the library.README.md describes this library and contains examples.