ebogi commented on a change in pull request #80: SQOOP-3438 Sqoop Import with 
create hcatalog table for ORC will not w…
URL: https://github.com/apache/sqoop/pull/80#discussion_r282975080
 
 

 ##########
 File path: src/test/org/apache/sqoop/hcat/HCatalogImportTest.java
 ##########
 @@ -770,6 +771,80 @@ public void testTableCreation() throws Exception {
       null, true, false);
   }
 
+  @Test
+  public void testExternalTableCreation() throws Exception {
+    final int TOTAL_RECORDS = 1 * 10;
+    String table = getTableName().toUpperCase();
+    ColumnGenerator[] cols = new ColumnGenerator[] {
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("1", 20), "1", KeyType.STATIC_KEY),
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("2", 20), "2", KeyType.DYNAMIC_KEY),
+    };
+    List<String> addlArgsArray = new ArrayList<String>();
+    addlArgsArray.add("--create-hcatalog-table");
+    addlArgsArray.add("--hcatalog-external-table");
+    addlArgsArray.add("--hcatalog-storage-stanza");
+    addlArgsArray.add("\"stored as orc tblproperties 
(\"transactional\"=\"false\")\"");
+    setExtraArgs(addlArgsArray);
+    utils.dropHCatTableIfExists(table, SqoopHCatUtilities.DEFHCATDB);
+    runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols,
+            null, true, false);
+  }
+
+  @Test
+  public void testExternalTableDropAndCreation() throws Exception {
+    final int TOTAL_RECORDS = 1 * 10;
+    String table = getTableName().toUpperCase();
+    ColumnGenerator[] cols = new ColumnGenerator[] {
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("1", 20), "1", KeyType.STATIC_KEY),
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("2", 20), "2", KeyType.DYNAMIC_KEY),
+    };
+    List<String> addlArgsArray = new ArrayList<String>();
+    addlArgsArray.add("--drop-and-create-hcatalog-table");
+    addlArgsArray.add("--hcatalog-external-table");
+    addlArgsArray.add("--hcatalog-storage-stanza");
+    addlArgsArray.add("\"stored as orc tblproperties 
(\"transactional\"=\"false\")\"");
+    setExtraArgs(addlArgsArray);
+    utils.dropHCatTableIfExists(table, SqoopHCatUtilities.DEFHCATDB);
+    runHCatImport(addlArgsArray, TOTAL_RECORDS, table, cols,
+            null, true, false);
+  }
+
+  @Test
+  public void testExternalTableCreationFailsIfNoCreateOrDropTablePresent() 
throws Exception {
+    final int TOTAL_RECORDS = 1 * 10;
+    String table = getTableName().toUpperCase();
+    ColumnGenerator[] cols = new ColumnGenerator[] {
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(0),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("1", 20), "1", KeyType.STATIC_KEY),
+            HCatalogTestUtils.colGenerator(HCatalogTestUtils.forIdx(1),
+                    "varchar(20)", Types.VARCHAR, HCatFieldSchema.Type.STRING, 
0, 0,
+                    new HiveVarchar("2", 20), "2", KeyType.DYNAMIC_KEY),
+    };
+    List<String> addlArgsArray = new ArrayList<String>();
+    addlArgsArray.add("--hcatalog-external-table");
+    addlArgsArray.add("--hcatalog-storage-stanza");
+    addlArgsArray.add("\"stored as orc tblproperties 
(\"transactional\"=\"false\")\"");
+    setExtraArgs(addlArgsArray);
+    utils.dropHCatTableIfExists(table, SqoopHCatUtilities.DEFHCATDB);
+    try {
 
 Review comment:
   Could you please use ExpectedException rule instead of using a try-catch 
block here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to