diff --git a/phoenix-core-client/src/main/java/org/apache/phoenix/schema/tool/SchemaSQLUtil.java b/phoenix-core-client/src/main/java/org/apache/phoenix/schema/tool/SchemaSQLUtil.java index 5ce73cb8f1f..c6dbf8bc8fe 100644 --- a/phoenix-core-client/src/main/java/org/apache/phoenix/schema/tool/SchemaSQLUtil.java +++ b/phoenix-core-client/src/main/java/org/apache/phoenix/schema/tool/SchemaSQLUtil.java @@ -112,7 +112,13 @@ private static String getColumnDefListToString(CreateTableStatement createStatem } private static String getColumnInfoString(ColumnDef cDef) { + String colFam = cDef.getColumnDefName().getFamilyName(); + String colDefName = cDef.getColumnDefName().getColumnName(); String colName = cDef.getColumnDefName().toString(); + if (colFam != null) { + colName = SchemaUtil.getEscapedArgument(colFam) + + "." + SchemaUtil.getEscapedArgument(colDefName); + } boolean isArrayType = cDef.getDataType().isArrayType(); String type = cDef.getDataType().getSqlTypeName(); Integer maxLength = cDef.getMaxLength(); @@ -169,8 +175,13 @@ private static void appendProperties(StringBuffer sb, if (prop.contains(".")) { prop = SchemaUtil.getEscapedArgument(prop); } - sb.append(prop).append("=") - .append(entry.getValue().getSecond()); + if (prop.equals("BLOOMFILTER")) { + sb.append(prop).append("=") + .append("'").append(entry.getValue().getSecond()).append("'"); + } else { + sb.append(prop).append("=") + .append(entry.getValue().getSecond()); + } sb.append(","); } sb.deleteCharAt(sb.length()-1); diff --git a/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolSynthesisIT.java b/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolSynthesisIT.java index 6d85d6c7038..4eaf27eb2e2 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolSynthesisIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/schema/tool/SchemaToolSynthesisIT.java @@ -234,8 +234,21 @@ public void testEscapedPropertyName() throws Exception { "(ORGANIZATION_ID CHAR(15) NOT NULL,\n" + "NETWORK_ID CHAR(15) NOT NULL\n" + "CONSTRAINT PK PRIMARY KEY (ORGANIZATION_ID))\n" + - "UPDATE_CACHE_FREQUENCY=172800000,DISABLE_BACKUP=true,MULTI_TENANT=true,REPLICATION_SCOPE=1,\"phoenix.max.lookback.age.seconds\"=0,VERSIONS=1"; + "BLOOMFILTER='ROW',UPDATE_CACHE_FREQUENCY=172800000,DISABLE_BACKUP=true,MULTI_TENANT=true,REPLICATION_SCOPE=1,\"phoenix.max.lookback.age.seconds\"=0,VERSIONS=1"; String baseDDL = filePath+"/escape_property.sql"; runAndVerify(expected, baseDDL); } + + @Test + public void testEscapedColumnName() throws Exception { + String expected = "CREATE TABLE IF NOT EXISTS ABC\n" + + "(NID CHAR(15) NOT NULL,\n" + + "DATA VARCHAR,\n" + + "\"a\".\"_\" CHAR(1),\n" + + "\"b\".\"_\" CHAR(1)\n" + + "CONSTRAINT PK PRIMARY KEY (NID))\n" + + "BLOOMFILTER='ROW',UPDATE_CACHE_FREQUENCY=172800000,DISABLE_BACKUP=true,MULTI_TENANT=true,REPLICATION_SCOPE=1,\"phoenix.max.lookback.age.seconds\"=0,VERSIONS=1"; + String baseDDL = filePath+"/escape_column.sql"; + runAndVerify(expected, baseDDL); + } } diff --git a/phoenix-core/src/it/resources/synthesis/escape_column.sql b/phoenix-core/src/it/resources/synthesis/escape_column.sql new file mode 100644 index 00000000000..0ccaedc5f24 --- /dev/null +++ b/phoenix-core/src/it/resources/synthesis/escape_column.sql @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +CREATE TABLE IF NOT EXISTS ABC (NID CHAR(15) NOT NULL, DATA VARCHAR, "a"."_" char(1), + "b"."_" char(1) CONSTRAINT PK PRIMARY KEY (NID)) VERSIONS=1,MULTI_TENANT=true,REPLICATION_SCOPE=1; +ALTER TABLE ABC SET DISABLE_BACKUP=TRUE; +ALTER TABLE ABC SET BLOOMFILTER='ROW'; +ALTER TABLE ABC SET "phoenix.max.lookback.age.seconds"=0; +ALTER TABLE ABC SET UPDATE_CACHE_FREQUENCY=172800000; \ No newline at end of file diff --git a/phoenix-core/src/it/resources/synthesis/escape_property.sql b/phoenix-core/src/it/resources/synthesis/escape_property.sql index ce266161b1d..8f7d35280ff 100644 --- a/phoenix-core/src/it/resources/synthesis/escape_property.sql +++ b/phoenix-core/src/it/resources/synthesis/escape_property.sql @@ -17,5 +17,6 @@ */ CREATE TABLE IF NOT EXISTS ABC (ORGANIZATION_ID CHAR(15) NOT NULL, NETWORK_ID CHAR(15) NOT NULL, CONSTRAINT PK PRIMARY KEY (ORGANIZATION_ID)) VERSIONS=1,MULTI_TENANT=true,REPLICATION_SCOPE=1; ALTER TABLE ABC SET DISABLE_BACKUP=TRUE; +ALTER TABLE ABC SET BLOOMFILTER='ROW'; ALTER TABLE ABC SET "phoenix.max.lookback.age.seconds"=0; ALTER TABLE ABC SET UPDATE_CACHE_FREQUENCY=172800000; \ No newline at end of file