richardantal commented on a change in pull request #1275:
URL: https://github.com/apache/phoenix/pull/1275#discussion_r678984841



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
##########
@@ -1238,6 +1238,78 @@ public static String 
getNormalizedColumnName(ColumnParseNode columnParseNode) {
         return columnParseNode.getName();
     }
 
+    public static String getFullTableNameWithQuotes(String schemaName, String 
tableName,
+    boolean schemaNameCaseSensitive, boolean tableNameCaseSensitive) {
+        String fullTableName;
+
+        if (tableNameCaseSensitive) {
+            fullTableName = "\"" + tableName + "\"";
+        } else {
+            fullTableName = tableName;
+        }
+
+        if(schemaName != null && schemaName.length() != 0) {
+            if (schemaNameCaseSensitive) {
+                fullTableName = "\"" + schemaName + "\"" + 
QueryConstants.NAME_SEPARATOR + fullTableName;
+            } else {
+                fullTableName = schemaName + QueryConstants.NAME_SEPARATOR + 
fullTableName;
+            }
+        }
+        return fullTableName;
+    }
+
+    public static String getFullTableNameWithQuotes(String schemaName, String 
tableName) {
+        return getFullTableNameWithQuotes(schemaName, tableName,
+                quotesNeededForSchema(schemaName), 
quotesNeededForTable(tableName));
+    }
+
+    private static boolean quotesNeededForSchema(String name) {
+        if (Strings.isNullOrEmpty(name) || 
name.equals(QueryConstants.DEFAULT_COLUMN_FAMILY)) {
+            return false;
+        }
+        return quotesNeededForTable(name);
+    }
+
+    private static boolean quotesNeededForColumn(String name) {
+        if (!name.equals("_INDEX_ID") && 
"_".equals(String.valueOf(name.charAt(0)))) {

Review comment:
       If we want to create a table named _FOO we need quotes around that. The 
same applies for column names.
   The difference is that when we create an index, _INDEX_ID column is added 
automatically and we do not want to have quotes around that. (But it should be 
possible to create a table called "_INDEX_ID" even if it an abnormal name.)




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


Reply via email to