NamsB7 commented on code in PR #4121: URL: https://github.com/apache/gobblin/pull/4121#discussion_r2225232191
########## gobblin-metastore/src/main/java/org/apache/gobblin/metastore/MysqlErrorPatternStore.java: ########## @@ -279,64 +302,46 @@ public List<ErrorPatternProfile> getErrorPatternsByCategory(String categoryName) } @Override - public Category getDefaultCategory() + public ErrorCategory getDefaultCategory() throws IOException { - if (hasIsDefaultColumn()) { - Category cat = getDefaultCategoryFromIsDefault(); + // 1. Try to use the configured default category name if set + if (configuredDefaultCategoryName != null && !configuredDefaultCategoryName.trim().isEmpty()) { + ErrorCategory cat = getErrorCategory(configuredDefaultCategoryName); if (cat != null) { return cat; + } else { + // Throw exception if configured category doesn't exist + throw new IOException(String.format( + "Configured default category '%s' not found in database", + configuredDefaultCategoryName)); } } - // Fallback to previous logic: category with the highest priority (lowest priority number) - return getHighestPriorityCategory(); - } - /** - * Returns the category with the highest priority, i.e. the lowest priority value (ascending order). - */ - private Category getHighestPriorityCategory() - throws IOException { - try (Connection conn = dataSource.getConnection(); PreparedStatement ps = conn.prepareStatement( - String.format(GET_HIGHEST_ERROR_CATEGORY_STATEMENT, errorCategoriesTable))) { - try (ResultSet rs = ps.executeQuery()) { - if (rs.next()) { - return new Category(rs.getString(1), rs.getInt(2)); - } - } - } catch (SQLException e) { - throw new IOException("Failed to get category", e); + // 2. No configuration provided - use lowest priority category as fallback + ErrorCategory lowestPriorityCategory = getLowestPriorityCategory(); + if (lowestPriorityCategory == null) { + throw new IOException("No error categories found in database"); } - return null; - } - /** - * Checks if the is_default column exists in the categories table. - */ - private boolean hasIsDefaultColumn() - throws IOException { - try (Connection conn = dataSource.getConnection()) { - try (ResultSet rs = conn.getMetaData().getColumns(null, null, errorCategoriesTable, "is_default")) { - return rs.next(); - } - } catch (SQLException e) { - throw new IOException("Failed to check for is_default column", e); - } + log.debug("No default category configured, using lowest priority category: {}", Review Comment: Addressed -- 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: dev-unsubscr...@gobblin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org