Skip to content

Commit

Permalink
Quote column name in Phoenix CREATE TABLE statement
Browse files Browse the repository at this point in the history
Additionally, enable testColumnName test in Phoenix.
  • Loading branch information
ebyhr committed Oct 4, 2020
1 parent 7ae3d96 commit cf8c7e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
import static org.apache.phoenix.coprocessor.BaseScannerRegionObserver.SKIP_REGION_BOUNDARY_CHECK;
import static org.apache.phoenix.util.PhoenixRuntime.getTable;
import static org.apache.phoenix.util.SchemaUtil.ESCAPE_CHARACTER;
import static org.apache.phoenix.util.SchemaUtil.getEscapedArgument;

public class PhoenixClient
extends BaseJdbcClient
Expand Down Expand Up @@ -389,7 +390,7 @@ public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, Connecto
typeStatement += " not null";
pkNames.add(columnName);
}
columnList.add(format("%s %s", columnName, typeStatement));
columnList.add(format("%s %s", getEscapedArgument(columnName), typeStatement));
}

ImmutableList.Builder<String> tableOptions = ImmutableList.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public void testCreateSchema()
}

@Override
public void testColumnName(String columnName)
protected boolean isColumnNameRejected(Exception exception, String columnName, boolean delimited)
{
// TODO (https://github.com/prestosql/presto/issues/3466) Phoenix generally lacks quoting in underlying queries
throw new SkipException("TODO");
// TODO This should produce a reasonable exception message like "Invalid column name". Then, we should verify the actual exception message
return columnName.equals("a\"quote");
}

@Override
Expand Down

0 comments on commit cf8c7e5

Please sign in to comment.