marton-bod commented on a change in pull request #2278:
URL: https://github.com/apache/iceberg/pull/2278#discussion_r584790632



##########
File path: mr/src/test/java/org/apache/iceberg/mr/hive/HiveIcebergTestUtils.java
##########
@@ -265,4 +278,57 @@ public static void validateFiles(Table table, 
Configuration conf, JobID jobId, i
     Assert.assertEquals(dataFileNum, dataFiles.size());
     Assert.assertFalse(new 
File(HiveIcebergOutputCommitter.generateJobLocation(conf, jobId)).exists());
   }
+
+  /**
+   * Lazy implementation for checking the the returned results from a SELECT 
statement are the same than the inserted
+   * values. We expect that the values are inserted using {@link 
#getStringValueForInsert(Object, Type)}.
+   * <p>
+   * For completeness shake we might want to implement sorting when needed.
+   * @param shell The shell used for executing the query
+   * @param tableName The name of the table to query
+   * @param expected The records we inserted
+   */
+  public static void validateDataWithSql(TestHiveShell shell, String 
tableName, List<Record> expected) {
+    List<Object[]> actual = shell.executeStatement("SELECT * from " + 
tableName);
+
+    for (int rowId = 0; rowId < expected.size(); ++rowId) {
+      Record record = expected.get(rowId);
+      Object[] row = actual.get(rowId);
+      Assert.assertEquals(record.size(), row.length);
+      for (int fieldId = 0; fieldId < record.size(); ++fieldId) {
+        Types.NestedField field = record.struct().fields().get(fieldId);
+        String inserted =
+            getStringValueForInsert(record.getField(field.name()), 
field.type()).replaceAll("'(.*)'", "$1");

Review comment:
       Yeah, the comment makes it much clearer.
   Maybe a small formatting suggestion? Let me know what you think.
   ```
   String inserted = getStringValueForInsert(record.getField(field.name()), 
field.type())
       // If there are enclosing quotes then remove them
       .replaceAll("'(.*)'", "$1");
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to