Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHOENIX-7552 : Escape bloomfilter value and column family in SchemaTool synthesis #2094

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
23 changes: 23 additions & 0 deletions phoenix-core/src/it/resources/synthesis/escape_column.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;