Refactor JDBCSource to add compile-time info about type of DB #1087
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This builds off @jcoveney's PR #1010. I figured I'd leave his branch alone, since this takes a slightly different approach.
Since we've pushed the type of DB for a source to compile time, opted to turn drivers into traits. Put all driver-specific logic there. (not only generating the correct SQL for table creation, but also things like getting the correct JDBCSchema).
JDBCSourceCompileTest
is an example source that exercises this code. IMO this is less boilerplate than having the driver as a generic type.I've also pulled out components of JDBCSource to its own file, since the one file was getting pretty gigantic.
[WIP] still need to do Vertica. Just thought I would get it out there for some comments.
Also had some offline discussions with @ianoc. This change requires that we change existing all JDBCSources, which is a lot of friction. Another possibility is to push SQL generation to run-time, after picking up the correct driver (currently the SQL to create the table is basically generated at compile time). This has the trade-off that
(positive) is a smaller change in API and allows us to swap databases
(negative) if a DB does not support a specific column or other such issues (mentioned by @jcoveney as an advantage to this approach in #1010) only manifest at run time.