Skip to content
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

Refactor JDBCSource to add compile-time info about type of DB #1087

Merged
merged 4 commits into from
Nov 10, 2014

Conversation

amatsukawa
Copy link
Contributor

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.

- Turn drivers into traits
- Put all driver-specific logic in those traits
@amatsukawa
Copy link
Contributor Author

Bump. I think it seems I'm getting more support for this approach rather than the run-time approach. Could someone review this?

Also let me know what you think about all the implicits using DriverColumnDefiner. Arguably we should just put convenience methods like int and double into each driver, and the drivers can provide whatever methods they want.

case class ColumnDefinition(name: ColumnName, definition: Definition)

trait ColumnDefiner {
val columns: Iterable[ColumnDefinition]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use def here to lesson the chance of a val init order null?

@johnynek
Copy link
Collaborator

This looks good to me. Just a couple of comments.

Since I'm OOO, I'd like if someone at Twitter would click merge.

@johnynek
Copy link
Collaborator

johnynek commented Nov 8, 2014

looks good to me. @ianoc merge?

ianoc added a commit that referenced this pull request Nov 10, 2014
Refactor JDBCSource to add compile-time info about type of DB
@ianoc ianoc merged commit fe08081 into develop Nov 10, 2014
@ianoc ianoc deleted the amatsukawa/jdbc_source_refactor branch November 10, 2014 13:27
@ianoc
Copy link
Collaborator

ianoc commented Nov 10, 2014

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants