stoty commented on a change in pull request #1275:
URL: https://github.com/apache/phoenix/pull/1275#discussion_r678881263
##########
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:
Why do we need the special case for tables beginning with underscore ?
Also getting the first character as string would can probably done in a less
circumpect way.
##########
File path:
phoenix-tools/src/main/java/org/apache/phoenix/schema/SchemaExtractionProcessor.java
##########
@@ -249,7 +261,7 @@ public String extractCreateTableDDL(PTable table) throws
IOException, SQLExcepti
private String generateTableDDLString(String columnInfoString, String
propertiesString,
String pSchemaName, String pTableName) {
- String pTableFullName =
SchemaUtil.getPTableFullNameWithQuotes(pSchemaName, pTableName);
+ String pTableFullName =
SchemaUtil.getFullTableNameWithQuotes(pSchemaName, pTableName);
Review comment:
You may want to go over the code, and change the quoted variable names
according to some common template, to improbe readability.
##########
File path:
phoenix-tools/src/it/java/org/apache/phoenix/schema/SchemaToolExtractionIT.java
##########
@@ -91,6 +104,42 @@ public void testCreateIndexStatement() throws Exception {
Assert.assertEquals(createIndexStatement2.toUpperCase(),
result.toUpperCase());
}
+ @Test
+ public void testCreateLocalIndexStatement() throws Exception {
Review comment:
It seems that you're also fixng some bugs WRT local indexes.
You should probablay note it at least in the commit message.
--
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]