soumyakanti3578 commented on code in PR #6197:
URL: https://github.com/apache/hive/pull/6197#discussion_r2662801121
##########
jdbc-handler/src/main/java/org/apache/hive/storage/jdbc/dao/GenericJdbcDatabaseAccessor.java:
##########
@@ -537,12 +539,27 @@ public boolean needColumnQuote() {
return true;
}
+ /**
+ * Quotes an identifier based on the database type.
+ *
+ * @param identifier The identifier to quote
+ * @param dbType The DatabaseType enum
+ * @return A database-specific quoted identifier (e.g., "\"Country\"" or
"`Country`")
+ */
+ protected static String quoteIdentifier(String identifier, DatabaseType
dbType) {
+ if (identifier == null || dbType == null || dbType.getStartQuote() ==
null) {
+ return identifier;
+ }
+ return dbType.getStartQuote() + identifier + dbType.getEndQuote();
+ }
+
private static String getQualifiedTableName(Configuration conf) {
- String tableName = conf.get(Constants.JDBC_TABLE);
+ DatabaseType dbType =
DatabaseType.from(conf.get(JdbcStorageConfig.DATABASE_TYPE.getPropertyName()));
+ String tableName =
quoteIdentifier(unescapeHiveJdbcIdentifier(conf.get(Constants.JDBC_TABLE)),
dbType);
if (tableName == null) {
return null;
}
- String schemaName = conf.get(Constants.JDBC_SCHEMA);
+ String schemaName =
quoteIdentifier(unescapeHiveJdbcIdentifier(conf.get(Constants.JDBC_SCHEMA)),
dbType);
Review Comment:
This method `getQualifiedTableName` is used to build queries that are run in
the backend db. We have to make sure to quote the table and schema names here,
if we want to support case sensitivity. Currently, if the user defines
`"hive.sql.table" = "Country"`, the table name in the query that is run in the
backend db is "essentially" `country`. And if we quote all the time we will be
changing the table name to `Country`, which might break existing jobs.
I think it's easy to check if the table and schema names were "escaped" by
the user before we "unescape" and quote. If they were not escaped, we could
skip it.
--
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]