This is an automated email from the ASF dual-hosted git repository. ankit pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new 9d15cc6 PHOENIX-5506 Psql load fails with lower table name 9d15cc6 is described below commit 9d15cc62a2dd0b00fc38258f73740e88177949cd Author: Ankit Singhal <an...@apache.org> AuthorDate: Mon Oct 7 11:17:29 2019 -0700 PHOENIX-5506 Psql load fails with lower table name --- .../apache/phoenix/end2end/CSVCommonsLoaderIT.java | 35 ++++++++++++++++++++++ .../org/apache/phoenix/util/CSVCommonsLoader.java | 3 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CSVCommonsLoaderIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CSVCommonsLoaderIT.java index 9b5581d..8db7afd 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/CSVCommonsLoaderIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/CSVCommonsLoaderIT.java @@ -23,7 +23,9 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.File; import java.io.StringReader; +import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -35,6 +37,7 @@ import java.util.Properties; import com.google.common.collect.ImmutableList; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; +import org.apache.commons.io.FileUtils; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixTestDriver; import org.apache.phoenix.schema.IllegalDataException; @@ -43,7 +46,9 @@ import org.apache.phoenix.schema.types.PArrayDataType; import org.apache.phoenix.util.CSVCommonsLoader; import org.apache.phoenix.util.DateUtil; import org.apache.phoenix.util.PhoenixRuntime; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; public class CSVCommonsLoaderIT extends ParallelStatsDisabledIT { @@ -98,6 +103,8 @@ public class CSVCommonsLoaderIT extends ParallelStatsDisabledIT { + "\n" + CSV_VALUES_BAD_ENCAPSULATED_CONTROL_CHARS; + @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); + @Test public void testCSVCommonsUpsert() throws Exception { CSVParser parser = null; @@ -766,4 +773,32 @@ public class CSVCommonsLoaderIT extends ParallelStatsDisabledIT { } } + + @Test public void testLowerCaseTable() throws Exception { + Connection conn = DriverManager.getConnection(getUrl()); + conn.setAutoCommit(true); + String tableName = generateUniqueName().toLowerCase(); + String t1 = generateUniqueName(); + String t2 = t1 + generateUniqueName(); + String csvFileName = "test.csv"; + conn.createStatement().execute("CREATE TABLE \"" + tableName + + "\" (k1 VARCHAR NOT NULL, k2 VARCHAR, CONSTRAINT PK PRIMARY KEY(K1,K2))"); + File tempFile = tempFolder.newFile(csvFileName); + FileUtils.writeStringToFile(tempFile, "'" + t1 + "','x'"); + try { + CSVCommonsLoader csvLoader = + new CSVCommonsLoader(conn.unwrap(PhoenixConnection.class), "" + tableName + "", + null, false, ',', '"', '\\', null); + csvLoader.upsert(tempFile.getAbsolutePath()); + } catch (Exception e) { + fail("Failed with Exception:" + e.getMessage()); + } + ResultSet rs = + conn.createStatement().executeQuery("SELECT * FROM \"" + tableName + "\" order by k2"); + assertTrue(rs.next()); + assertEquals("'"+t1+"'",rs.getString(1)); + assertEquals("'"+"x"+"'",rs.getString(2)); + assertFalse(rs.next()); + + } } \ No newline at end of file diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java index 024e3cd..bd98bff 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java @@ -211,7 +211,8 @@ public class CSVCommonsLoader { long start = System.currentTimeMillis(); CsvUpsertListener upsertListener = new CsvUpsertListener(conn, conn.getMutateBatchSize(), isStrict); - CsvUpsertExecutor csvUpsertExecutor = new CsvUpsertExecutor(conn, tableName, + CsvUpsertExecutor csvUpsertExecutor = new CsvUpsertExecutor(conn, + SchemaUtil.getEscapedFullTableName(tableName), columnInfoList, upsertListener, arrayElementSeparator); csvUpsertExecutor.execute(csvParser);