soumyakanti3578 commented on code in PR #6727:
URL: https://github.com/apache/hive/pull/6727#discussion_r3897066497


##########
ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java:
##########
@@ -5151,4 +5151,34 @@ public static void setTableCreateTime(Configuration 
conf, Table table) {
   public static int getTableCreateTime(Configuration conf, String tableName) {
     return conf.getInt(String.format("%s.%s", tableName, CREATE_TIME), 0);
   }
+
+  /**
+   * Returns the physical (unquoted) form of a JDBC identifier supplied 
through table properties such as
+   * {@code hive.sql.table} or {@code hive.sql.schema}, for use in contexts 
that need the identifier exactly as
+   * stored in the remote catalog (JDBC metadata lookups, Calcite resolution, 
authorization URIs).
+   *
+   * <p>Recognises ANSI/Oracle/Postgres double quotes ({@code "id"}), 
MySQL/MariaDB back-ticks ({@code `id`}) and
+   * SQL Server brackets ({@code [id]}). Unquoted identifiers are returned 
unchanged.
+   */
+  public static String unquoteJdbcIdentifier(String identifier) {
+    if (identifier == null || identifier.length() < 2) {
+      return identifier;
+    }
+    char start = identifier.charAt(0);
+    char end = identifier.charAt(identifier.length() - 1);
+    final char closing;
+    if (start == '"' || start == '`') {
+      closing = start;
+    } else if (start == '[') {
+      closing = ']';
+    } else {
+      return identifier;
+    }
+    if (end != closing) {
+      return identifier;
+    }
+    String inner = identifier.substring(1, identifier.length() - 1);
+    // A literal quote char inside a quoted identifier is escaped by doubling 
it.

Review Comment:
   I see what you mean, and I will update it! Thanks



-- 
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]

Reply via email to