paul-rogers commented on a change in pull request #1993: DRILL-7601: Shift 
column conversion to reader from scan framework
URL: https://github.com/apache/drill/pull/1993#discussion_r390511107
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/text/compliant/TestCsvTableProperties.java
 ##########
 @@ -547,4 +543,65 @@ public void testMessyQuotes() throws Exception {
         .build();
     RowSetUtilities.verify(expected, actual);
   }
+
+  private static final String[] trimData = {
+      " 10 , fred ",
+      " 20, wilma "
+    };
+
+  /**
+   * Trim leading and trailing whitespace. This setting is currently
+   * only available via table properties.
+   */
+  @Test
+  public void testKeepWitespace() throws Exception {
+    try {
+      enableSchemaSupport();
+      String tablePath = buildTable("noTrim", trimData);
+      String sql = String.format("create schema (%s) " +
+          "for table %s PROPERTIES ('" +
+          TextFormatPlugin.HAS_HEADERS_PROP + "'='false', '" +
+          TextFormatPlugin.SKIP_FIRST_LINE_PROP + "'='false')",
+          COL_SCHEMA, tablePath);
+      run(sql);
+      RowSet actual = client.queryBuilder().sql(SELECT_ALL, 
tablePath).rowSet();
+
+      TupleMetadata expectedSchema = new SchemaBuilder()
+          .add("id", MinorType.INT)
+          .add("name", MinorType.VARCHAR)
+          .buildSchema();
+
+      // String-to-number conversion trims strings automatically
+      RowSet expected = new RowSetBuilder(client.allocator(), expectedSchema)
+          .addRow(10, " fred ")
+          .addRow(20, " wilma ")
+          .build();
+      RowSetUtilities.verify(expected, actual);
+    } finally {
+      resetSchemaSupport();
+    }
+  }
+
+ /**
+   * Trim leading and trailing whitespace. This setting is currently
+   * only available via table properties.
+   */
+  @Test
+  public void testTrimWitespace() throws Exception {
+    try {
+      enableSchemaSupport();
+      String tablePath = buildTable("trim", trimData);
+      String sql = String.format("create schema (%s) " +
+          "for table %s PROPERTIES ('" +
+          TextFormatPlugin.HAS_HEADERS_PROP + "'='false', '" +
+          TextFormatPlugin.SKIP_FIRST_LINE_PROP + "'='false', '" +
+          TextFormatPlugin.TRIM_WHITESPACE_PROP + "'='true')",
 
 Review comment:
   Added detail to the "Documentation" section of this PR. There will be a few 
more new properties for JSON. Then I'll figure out how to show that in the 
docs. Perhaps in the provided schema section we need a table of which formats 
support the schema, and which properties each format supports, and what they do.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to