You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gr...@apache.org on 2014/05/19 09:23:14 UTC

git commit: PHOENIX-986 Better err message for CSV import

Repository: incubator-phoenix
Updated Branches:
  refs/heads/master bd126fa6a -> cd75ada38


PHOENIX-986 Better err message for CSV import

Supply a more clear error message for the CSV import if the
supplied table name does not match an existing table name.


Project: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/commit/cd75ada3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/tree/cd75ada3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-phoenix/diff/cd75ada3

Branch: refs/heads/master
Commit: cd75ada38f9016427bd3d44f5afda1283bca981a
Parents: bd126fa
Author: Gabriel Reid <gr...@apache.org>
Authored: Sat May 17 22:48:54 2014 +0200
Committer: Gabriel Reid <ga...@ngdata.com>
Committed: Mon May 19 09:15:43 2014 +0200

----------------------------------------------------------------------
 .../phoenix/end2end/CSVCommonsLoaderIT.java     | 21 ++++++++++++++++++++
 .../apache/phoenix/util/CSVCommonsLoader.java   |  3 +++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/cd75ada3/phoenix-core/src/it/java/org/apache/phoenix/end2end/CSVCommonsLoaderIT.java
----------------------------------------------------------------------
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 1704e8f..f75a13e 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
@@ -600,4 +600,25 @@ public class CSVCommonsLoaderIT extends BaseHBaseManagedTimeIT {
         }
     }
 
+    @Test
+    public void testCSVCommonsUpsert_NonExistentTable() throws Exception {
+        PhoenixConnection conn = null;
+        try {
+            conn = DriverManager.getConnection(getUrl()).unwrap(
+                    PhoenixConnection.class);
+            CSVCommonsLoader csvUtil = new CSVCommonsLoader(conn, "NONEXISTENTTABLE",
+                    null, true, ',', '"', null, "!");
+            csvUtil.upsert(
+                    new StringReader("ID,VALARRAY\n"
+                            + "1,2!3!4\n"));
+            fail("Trying to load a non-existent table should fail");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Table NONEXISTENTTABLE not found", e.getMessage());
+        } finally {
+            if (conn != null) {
+                conn.close();
+            }
+        }
+
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/cd75ada3/phoenix-core/src/main/java/org/apache/phoenix/util/CSVCommonsLoader.java
----------------------------------------------------------------------
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 8d67e20..494696b 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
@@ -299,6 +299,9 @@ public class CSVCommonsLoader {
                         rs.getString(QueryUtil.COLUMN_NAME_POSITION),
                         PDataType.fromSqlTypeName(sqlTypeName).getSqlType());
             }
+            if (columnNameToTypeMap.isEmpty()) {
+                throw new IllegalArgumentException("Table " + tableName + " not found");
+            }
         } finally {
             if (rs != null) {
                 rs.close();