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); ``` -- 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. To unsubscribe, e-mail: dev-unsubscr...@drill.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org