ebyhr commented on code in PR #14603:
URL: https://github.com/apache/iceberg/pull/14603#discussion_r2548213468
##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -264,6 +261,71 @@ private void updateSchemaIfRequired() {
}
}
+ private boolean isOracle(Connection conn) {
+ try {
+ String databaseProductName = conn.getMetaData().getDatabaseProductName();
+ return databaseProductName != null
+ && databaseProductName.toLowerCase(Locale.ROOT).contains("oracle");
+ } catch (SQLException e) {
+ throw new UncheckedSQLException(e, "Cannot determine database product
name");
+ }
+ }
+
+ private boolean tableExists(Connection conn, String tableNamePattern) throws
SQLException {
+ DatabaseMetaData dbMeta = conn.getMetaData();
+
+ String[] tableVariants =
+ new String[] {
+ tableNamePattern,
+ tableNamePattern == null ? null :
tableNamePattern.toUpperCase(Locale.ROOT),
+ tableNamePattern == null ? null :
tableNamePattern.toLowerCase(Locale.ROOT)
+ };
+
+ for (String t : tableVariants) {
+ if (t == null) {
+ continue;
+ }
Review Comment:
When do we receive null as `tableNamePattern`? If that’s unexpected, it
would be better to throw an exception rather than silently ignoring it. The
same applies to the `columnExists` method.
##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -264,6 +261,71 @@ private void updateSchemaIfRequired() {
}
}
+ private boolean isOracle(Connection conn) {
Review Comment:
nit: This method can be static. Same for others.
##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -264,6 +261,71 @@ private void updateSchemaIfRequired() {
}
}
+ private boolean isOracle(Connection conn) {
+ try {
+ String databaseProductName = conn.getMetaData().getDatabaseProductName();
+ return databaseProductName != null
+ && databaseProductName.toLowerCase(Locale.ROOT).contains("oracle");
+ } catch (SQLException e) {
+ throw new UncheckedSQLException(e, "Cannot determine database product
name");
+ }
+ }
+
+ private boolean tableExists(Connection conn, String tableNamePattern) throws
SQLException {
+ DatabaseMetaData dbMeta = conn.getMetaData();
+
+ String[] tableVariants =
+ new String[] {
+ tableNamePattern,
+ tableNamePattern == null ? null :
tableNamePattern.toUpperCase(Locale.ROOT),
+ tableNamePattern == null ? null :
tableNamePattern.toLowerCase(Locale.ROOT)
Review Comment:
The 3rd entity looks redundant since `tableNamePattern` is always lowercase
- JdbcUtil.CATALOG_TABLE_VIEW_NAME (`iceberg_tables`) or
JdbcUtil.NAMESPACE_PROPERTIES_TABLE_NAME (`iceberg_namespace_properties`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]