[ 
https://issues.apache.org/jira/browse/DRILL-8256?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17566343#comment-17566343
 ] 

ASF GitHub Bot commented on DRILL-8256:
---------------------------------------

jnturton commented on code in PR #2592:
URL: https://github.com/apache/drill/pull/2592#discussion_r920142742


##########
exec/java-exec/src/test/java/org/apache/drill/test/QueryBuilder.java:
##########
@@ -281,19 +281,31 @@ public QueryBuilder physical(String plan) {
   }
 
   /**
-   * Run a query contained in a resource file.
+   * Parse a single SQL statement (with optional ending semi-colon) from
+   * the resource provided.
    *
-   * @param resource Name of the resource
+   * @param resource the resource containing exactly one SQL statement, with
+   * optional ending semi-colon
    * @return this builder
    */
-  public QueryBuilder sqlResource(String resource) {
-    sql(ClusterFixture.loadResource(resource));
-    return this;
+  public QueryBuilder sqlResource(String resource) throws IOException {
+    String script = ClusterFixture.loadResource(resource);
+    StatementParser parser = new StatementParser(script);
+    String sql = parser.parseNext();
+    if (sql == null) {
+      throw new IllegalArgumentException("No query found");
+    }
+    return sql(sql);
   }
 
-  public QueryBuilder sqlResource(String resource, Object... args) {
-    sql(ClusterFixture.loadResource(resource), args);
-    return this;
+  public QueryBuilder sqlResource(String resource, Object... args) throws 
IOException {
+    String script = ClusterFixture.loadResource(resource);
+    StatementParser parser = new StatementParser(script);
+    String sql = parser.parseNext();
+    if (sql == null) {
+      throw new IllegalArgumentException("No query found");
+    }
+    return sql(sql);

Review Comment:
   ```suggestion
       return sql(sql, args);
   ```





> Fix unit tests of Kerberos auth in RPC 
> ---------------------------------------
>
>                 Key: DRILL-8256
>                 URL: https://issues.apache.org/jira/browse/DRILL-8256
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Security
>    Affects Versions: 1.20.1
>            Reporter: James Turton
>            Assignee: James Turton
>            Priority: Minor
>             Fix For: 1.20.2
>
>
> Minor bugs in some unit tests in org.apache.drill.exec.rpc.user.security have 
> meant that they have been disabled historically to prevent causing CI 
> failures.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to