arina-ielchiieva 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_r384454702
 
 

 ##########
 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:
   Also we should update the docs, indicating this new property.

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