From 8c52be81d38b474f57427717bc548c0b205d998e Mon Sep 17 00:00:00 2001 From: Akshat Jain Date: Thu, 17 Oct 2024 15:48:22 +0530 Subject: [PATCH] Fix postgres metadata storage warning logs because of tablename causing issues (#17351) --- .../postgresql/PostgreSQLConnector.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java b/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java index b44d57115cf..f0b9ba0b4a0 100644 --- a/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java +++ b/extensions-core/postgresql-metadata-storage/src/main/java/org/apache/druid/metadata/storage/postgresql/PostgreSQLConnector.java @@ -42,6 +42,7 @@ import java.sql.DatabaseMetaData; import java.sql.SQLException; import java.util.List; import java.util.Locale; +import java.util.Set; public class PostgreSQLConnector extends SQLMetadataConnector { @@ -287,4 +288,24 @@ public class PostgreSQLConnector extends SQLMetadataConnector } return false; } + + /** + * This method has been overridden to pass lowercase tableName. + * This is done because PostgreSQL creates tables with lowercased names unless explicitly enclosed in double quotes. + */ + @Override + protected boolean tableHasColumn(String tableName, String columnName) + { + return super.tableHasColumn(StringUtils.toLowerCase(tableName), columnName); + } + + /** + * This method has been overridden to pass lowercase tableName. + * This is done because PostgreSQL creates tables with lowercased names unless explicitly enclosed in double quotes. + */ + @Override + public Set getIndexOnTable(String tableName) + { + return super.getIndexOnTable(StringUtils.toLowerCase(tableName)); + } }