Skip to content
Closed
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 numberDiff line numberDiff line change
Expand Up@@ -206,8 +206,8 @@ public void testImportWithTabsAndEmptyQuotes() throws Exception {
"--input", "/tmp/input8.csv",
"--table", "table8",
"--zookeeper", zkQuorum,
"-q", "\"\"",
"-e", "\"\"",
"-q", "",
"-e", "",
"--delimiter", "\\t"
});
assertEquals(0, exitCode);
Expand DownExpand Up@@ -701,7 +701,7 @@ public void testImportWithUpperCaseSchemaNameAndLowerCaseTableName() throws Exce
csvBulkLoadTool.getConf().set(DATE_FORMAT_ATTRIB,"yyyy/MM/dd");
int exitCode = csvBulkLoadTool.run(new String[] {
"--input", "/tmp/input1.csv",
"--table", "\"\"t\"\"",
"--table", "\"t\"",
"--schema", "S",
"--zookeeper", zkQuorum});
assertEquals(0, exitCode);
Expand DownExpand Up@@ -736,7 +736,7 @@ public void testImportWithLowerCaseSchemaNameAndUpperCaseTableName() throws Exce
int exitCode = csvBulkLoadTool.run(new String[] {
"--input", "/tmp/input1.csv",
"--table", "T",
"--schema", "\"\"s\"\"",
"--schema", "\"s\"",
"--zookeeper", zkQuorum});
assertEquals(0, exitCode);
ResultSet rs = stmt.executeQuery("SELECT id, name, t FROM \"s\".T ORDER BY id");
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,11 +29,11 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
Expand DownExpand Up@@ -123,7 +123,7 @@ protected CommandLine parseOptions(String[] args) {

Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand DownExpand Up@@ -178,40 +178,12 @@ public int run(String[] args) throws Exception {
return loadData(conf, cmdLine);
}

/**
* Check schema or table name that start with two double quotes i.e ""t"" -> true
*/
private boolean isStartWithTwoDoubleQuotes (String name) {
boolean start = false;
boolean end = false;
if (name != null && name.length() > 1) {
int length = name.length();
start = name.substring(0,2).equals("\"\"");
end = name.substring(length-2, length).equals("\"\"");
if (start && !end) {
throw new IllegalArgumentException("Invalid table/schema name " + name +
". Please check if name end with two double quotes.");
}
}
return start;
}


private int loadData(Configuration conf, CommandLine cmdLine) throws Exception {
String tableName = cmdLine.getOptionValue(TABLE_NAME_OPT.getOpt());
String schemaName = cmdLine.getOptionValue(SCHEMA_NAME_OPT.getOpt());
String indexTableName = cmdLine.getOptionValue(INDEX_TABLE_NAME_OPT.getOpt());
boolean quotedTableName = isStartWithTwoDoubleQuotes(tableName);
if (quotedTableName) {
// Commons-cli cannot parse full quoted argument i.e "t" (CLI-275).
// if \"\"t\"\" passed, then both pairs of quoted are left intact as ""t"".
// So remove one pair of quote from tablename ""t"" -> "t".
tableName = tableName.substring(1, tableName.length() - 1);
}
boolean quotedSchemaName = isStartWithTwoDoubleQuotes(schemaName);
if (quotedSchemaName) {
schemaName = schemaName.substring(1,schemaName.length() - 1);
}

String qualifiedTableName = SchemaUtil.getQualifiedTableName(schemaName, tableName);
String qualifiedIndexTableName = null;
if (indexTableName != null){
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,11 +49,11 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
Expand DownExpand Up@@ -194,7 +194,7 @@ private void parseOptions(String[] args) throws Exception {

final Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,10 +19,10 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
Expand DownExpand Up@@ -173,7 +173,7 @@ public int getBatchSize() {

public CommandLine parseOptions(String[] args) {
final Options options = getOptions();
CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,11 +26,11 @@
import com.google.inject.Inject;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
Expand DownExpand Up@@ -170,7 +170,7 @@ private Options getOptions() {
private CommandLine parseOptions(String[] args) {
final Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -352,7 +352,7 @@ public CommandLine parseOptions(String[] args) {

final Options options = getOptions();

CommandLineParser parser = new DefaultParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,11 +21,11 @@
import com.google.common.base.Strings;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hbase.HConstants;
Expand DownExpand Up@@ -225,7 +225,7 @@ public CommandLine parseOptions(String[] args) {

final Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,11 +20,11 @@
import org.antlr.runtime.CharStream;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseConfiguration;
Expand DownExpand Up@@ -263,7 +263,7 @@ CommandLine parseOptions(String[] args) {

final Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,11 +19,11 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.hbase.HBaseConfiguration;
Expand DownExpand Up@@ -55,7 +55,7 @@ private void parseOptions(String[] args) throws Exception {

final Options options = getOptions();

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,11 +46,11 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
Expand DownExpand Up@@ -702,7 +702,7 @@ public static ExecutionCommand parseArgs(String[] args) {
options.addOption(localIndexUpgradeOption);
options.addOption(binaryEncodingOption);

CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,10 +28,10 @@
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.phoenix.pherf.PherfConstants.CompareType;
import org.apache.phoenix.pherf.PherfConstants.GeneratePhoenixStats;
import org.apache.phoenix.pherf.configuration.DataModel;
Expand DownExpand Up@@ -129,7 +129,7 @@ public class Pherf {
WorkloadExecutor workloadExecutor;

public Pherf(String[] args) throws Exception {
CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine command = null;
HelpFormatter hf = new HelpFormatter();

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,11 +19,11 @@

import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLine;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.CommandLineParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.DefaultParser;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
Expand DownExpand Up@@ -83,7 +83,7 @@ private void populateToolAttributes(String[] args) {

private CommandLine parseOptions(String[] args) {
final Options options = getOptions();
CommandLineParser parser = new PosixParser();
CommandLineParser parser = new DefaultParser(false, false);
CommandLine cmdLine = null;
try {
cmdLine = parser.parse(options, args);
Expand Down