-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 create/insert base jdbc client #19224
Refactor create/insert base jdbc client #19224
Conversation
today we have lots of connectors which override entire beginInsert method for example even though they just want to change the generated query. And then over time the super impl improves to handle bugs or new features for example but the overridden code starts getting stale
for (ColumnMetadata column : columns) { | ||
String columnName = identifierMapping.toRemoteColumnName(remoteIdentifiers, column.getName()); | ||
verifyColumnName(connection.getMetaData(), columnName); | ||
columnNames.add(columnName); | ||
columnTypes.add(column.getType()); | ||
columnList.add(getColumnDefinitionSql(session, column, columnName)); | ||
} | ||
|
||
Optional<String> pageSinkIdColumnName = Optional.empty(); | ||
if (pageSinkIdColumn.isPresent()) { | ||
String columnName = identifierMapping.toRemoteColumnName(remoteIdentifiers, pageSinkIdColumn.get().getName()); | ||
pageSinkIdColumnName = Optional.of(columnName); | ||
verifyColumnName(connection.getMetaData(), columnName); | ||
columnList.add(getColumnDefinitionSql(session, pageSinkIdColumn.get(), columnName)); | ||
} | ||
|
||
RemoteTableName remoteTableName = new RemoteTableName(Optional.ofNullable(catalog), Optional.ofNullable(remoteSchema), remoteTargetTableName); | ||
for (String sql : createTableSqls(remoteTableName, columnList.build(), tableMetadata)) { | ||
execute(session, connection, sql); |
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.
let's keep just this section as the overridable part because this is the section which generates SQL via getColumnDefinitionSql
and createTableSqls
. Everything above this is something which MUST be common for all base-jdbc connectors anyway since it includes identifier mapping and naming rules.
Same for all the other methods.
87a5218
to
5a06e25
Compare
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.
Thanks. LGTM.
Can you please squash the commits?
Nevermind, I can use "Squash and merge" button.
today we have lots of connectors which override entire beginInsert method for example even though they just want to change the generated query. And then over time the super impl improves to handle bugs or new features for example but the overridden code starts getting stale
Description
Additional context and related issues
Release notes
(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text: