Daniel Barclay (Drill) created DRILL-3863: ---------------------------------------------
Summary: TestBuilder.baseLineColumns(...) doesn't take net strings; parses somehow--can't test some names Key: DRILL-3863 URL: https://issues.apache.org/jira/browse/DRILL-3863 Project: Apache Drill Issue Type: Bug Components: Tools, Build & Test Reporter: Daniel Barclay (Drill) Assignee: Jason Altekruse {{TestBuilder}}'s {{baseLineColumns(String...)}} method doesn't take the given strings as net column names, and instead tries to parse them somehow, but doesn't parse them as the SQL parser would (and that method's Javadoc documentation doesn't seem to say how the strings are parsed/interpreted or indicate any third way of specifying arbitrary net column names). That means that certain column names _cannot be checked_ for (cannot be used in the result set being checked). For example, in Drill, the SQL delimited identifier "{{`Column B`}}" specifies a net column name of "{{Column B}}". However, passing that net column name (that is, a {{String}} representing that net column name) to {{baseLineColumns}} results in a strange parsing error. (See Test Class 1 and the error in Failure Trace 1.) Checking whether {{baseLineColumns}} takes SQL-level syntax for column names rather than net column names (by passing a string including the back-quote characters of the delimited identifier) seems to indicate that {{baseLineColumns}} doesn't take that syntax that either. (See Test Class 2 and the three expected/returned records in Failure Trace 2.) That seems to mean that it's impossible to use {{baseLineColumns}} to validate certain column names (including the fairly simple/common case of alias names containing spaces for output formatting purposes). Test Class 1: {noformat} import org.junit.Test; public class TestTEMPFileNameBugs extends BaseTestQuery { @Test public void test1() throws Exception { testBuilder() .sqlQuery( "SELECT * FROM ( VALUES (1, 2) ) AS T(column_a, `Column B`)" ) .unOrdered() .baselineColumns("column_a", "Column B") .baselineValues(1, 2) .go(); } } {noformat} Failure Trace 1: {noformat} org.apache.drill.common.exceptions.ExpressionParsingException: Expression has syntax error! line 1:0:no viable alternative at input 'Column' at org.apache.drill.common.expression.parser.ExprParser.displayRecognitionError(ExprParser.java:169) at org.antlr.runtime.BaseRecognizer.reportError(BaseRecognizer.java:186) at org.apache.drill.common.expression.parser.ExprParser.lookup(ExprParser.java:5163) at org.apache.drill.common.expression.parser.ExprParser.atom(ExprParser.java:4370) at org.apache.drill.common.expression.parser.ExprParser.unaryExpr(ExprParser.java:4252) at org.apache.drill.common.expression.parser.ExprParser.xorExpr(ExprParser.java:3954) at org.apache.drill.common.expression.parser.ExprParser.mulExpr(ExprParser.java:3821) at org.apache.drill.common.expression.parser.ExprParser.addExpr(ExprParser.java:3689) at org.apache.drill.common.expression.parser.ExprParser.relExpr(ExprParser.java:3564) at org.apache.drill.common.expression.parser.ExprParser.equExpr(ExprParser.java:3436) at org.apache.drill.common.expression.parser.ExprParser.andExpr(ExprParser.java:3310) at org.apache.drill.common.expression.parser.ExprParser.orExpr(ExprParser.java:3185) at org.apache.drill.common.expression.parser.ExprParser.condExpr(ExprParser.java:3110) at org.apache.drill.common.expression.parser.ExprParser.expression(ExprParser.java:3041) at org.apache.drill.common.expression.parser.ExprParser.parse(ExprParser.java:206) at org.apache.drill.TestBuilder.parsePath(TestBuilder.java:202) at org.apache.drill.TestBuilder.baselineColumns(TestBuilder.java:333) at org.apache.drill.TestTEMPFileNameBugs.test1(TestTEMPFileNameBugs.java:30) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) {noformat} Test Class 2: {noformat} import org.junit.Test; public class TestTEMPFileNameBugs extends BaseTestQuery { @Test public void test1() throws Exception { testBuilder() .sqlQuery( "SELECT * FROM ( VALUES (1, 2) ) AS T(column_a, `Column B`)" ) .unOrdered() .baselineColumns("column_a", "`Column B`") .baselineValues(1, 2) .go(); } } {noformat} Failure Trace 2: {noformat} java.lang.Exception: After matching 0 records, did not find expected record in result set: `Column B` : 2, `column_a` : 1, Some examples of expected records:`Column B` : 2, `column_a` : 1, Some examples of records returned by the test query:`Column B` : 2, `column_a` : 1, at org.apache.drill.DrillTestWrapper.compareResults(DrillTestWrapper.java:577) at org.apache.drill.DrillTestWrapper.compareUnorderedResults(DrillTestWrapper.java:303) at org.apache.drill.DrillTestWrapper.run(DrillTestWrapper.java:125) at org.apache.drill.TestBuilder.go(TestBuilder.java:129) at org.apache.drill.TestTEMPFileNameBugs.test1(TestTEMPFileNameBugs.java:33) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.lang.reflect.Method.invoke(Method.java:606) {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)