arina-ielchiieva commented on a change in pull request #1807: DRILL-7293: 
Convert the regex ("log") plugin to use EVF
URL: https://github.com/apache/drill/pull/1807#discussion_r301666390
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/store/log/TestLogReader.java
 ##########
 @@ -607,4 +611,65 @@ public void testSchemaOnlyWithMissingCols() throws 
Exception {
       client.resetSession(ExecConstants.STORE_TABLE_USE_SCHEMA_FILE);
     }
   }
+
+  @Test
+  public void testEmptyPattern() throws Exception {
+    String tablePath = buildTable(tableFuncDir, "tf", "emptyRegex",
+        "sample.logf", "/regex/simple.log1");
+    try {
+     String sql = "SELECT * FROM %s";
+     client.queryBuilder().sql(sql, tablePath).run();
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Regex property is required"));
+    }
+  }
+
+  /**
+   * Test the ability to use table functions to specify the regex.
+   */
+
+  @Test
+  public void testTableFunction() throws Exception {
+    String tablePath = buildTable(tableFuncDir, "tf", "table1",
+        "sample.logf", "/regex/simple.log1");
+
+    // Run a query using a table function.
+
+    String escaped = DATE_ONLY_PATTERN.replace("\\", "\\\\");
+    String sql = "SELECT * FROM table(%s(type => '%s', regex => '%s', 
maxErrors => 10))";
+    // String sql = "SELECT * FROM %s";
+    RowSet results = client.queryBuilder().sql(sql, tablePath, 
LogFormatPlugin.PLUGIN_NAME, escaped).rowSet();
+
+    // Verify that the returned data used the schema.
+
+    BatchSchema expectedSchema = new SchemaBuilder()
+        .addNullable("field_0", MinorType.VARCHAR)
+        .addNullable("field_1", MinorType.VARCHAR)
+        .addNullable("field_2", MinorType.VARCHAR)
+        .build();
+
+    RowSet expected = client.rowSetBuilder(expectedSchema)
+        .addRow("2017", "12", "17")
+        .addRow("2017", "12", "18")
+        .addRow("2017", "12", "19")
+        .build();
+
+    RowSetUtilities.verify(expected, results);
+  }
+
+  @Test
+  public void testTableFunctionNoGroups() throws Exception {
+    String tablePath = buildTable(tableFuncDir, "tf", "noGroups",
+        "sample.logf", "/regex/simple.log1");
+
+    // Use a table function to pass in a regex without a group.
+
+    try {
+      String sql = "SELECT * FROM table(%s(type => '%s', regex => '''foo'''))";
+      client.queryBuilder().sql(sql, tablePath, 
LogFormatPlugin.PLUGIN_NAME).run();
 
 Review comment:
   Same 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:
[email protected]


With regards,
Apache Git Services

Reply via email to