mirror of https://github.com/apache/druid.git
fix
This commit is contained in:
parent
f104ce46b9
commit
145fe8215b
|
@ -86,6 +86,7 @@ import org.apache.druid.server.security.AuthenticationResult;
|
|||
import org.apache.druid.server.security.ForbiddenException;
|
||||
import org.apache.druid.server.security.ResourceAction;
|
||||
import org.apache.druid.sql.SqlStatementFactory;
|
||||
import org.apache.druid.sql.calcite.QueryTestRunner.QueryResults;
|
||||
import org.apache.druid.sql.calcite.expression.DruidExpression;
|
||||
import org.apache.druid.sql.calcite.planner.Calcites;
|
||||
import org.apache.druid.sql.calcite.planner.PlannerConfig;
|
||||
|
@ -120,6 +121,8 @@ import org.junit.rules.ExpectedException;
|
|||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
|
@ -1054,6 +1057,36 @@ public class BaseCalciteQueryTest extends CalciteTestBase
|
|||
}
|
||||
}
|
||||
|
||||
public void assertResultsValid(String message, List<Object[]> expected, QueryResults queryResults)
|
||||
{
|
||||
|
||||
List<Object[]> results = queryResults.results;
|
||||
int numRows = Math.min(results.size(), expected.size());
|
||||
for (int row = 0; row < numRows; row++) {
|
||||
Object[] expectedRow = expected.get(row);
|
||||
Object[] resultRow = results.get(row);
|
||||
assertEquals("column count mismatch; at row#" + row, expectedRow.length, resultRow.length);
|
||||
|
||||
for (int i = 0; i < resultRow.length; i++) {
|
||||
Object resultCell = resultRow[i];
|
||||
Object expectedCell = expectedRow[i];
|
||||
|
||||
if(expectedCell == null) {
|
||||
if(resultCell == null) {
|
||||
continue;
|
||||
}
|
||||
expectedCell = NullHandling.defaultValueForType(queryResults.signature.getColumnType(i).get().getType());
|
||||
}
|
||||
assertEquals(
|
||||
String.format("column content mismatch at %d,%d", row, i),
|
||||
expectedCell,
|
||||
resultCell);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void assertResultsEquals(String sql, List<Object[]> expectedResults, List<Object[]> results)
|
||||
{
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
|
|
|
@ -79,9 +79,7 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest
|
|||
final URL windowFolderUrl = ClassLoader.getSystemResource("calcite/tests/window");
|
||||
File windowFolder = new File(windowFolderUrl.toURI());
|
||||
|
||||
final File[] listedFiles = windowFolder.listFiles(
|
||||
pathname -> pathname.getName().toLowerCase(Locale.ROOT).endsWith(".sqltest")
|
||||
);
|
||||
final File[] listedFiles = windowFolder.listFiles(pathname -> pathname.getName().toLowerCase(Locale.ROOT).endsWith(".sqltest"));
|
||||
|
||||
return Arrays
|
||||
.stream(Objects.requireNonNull(listedFiles))
|
||||
|
@ -198,12 +196,11 @@ public class CalciteWindowQueryTest extends BaseCalciteQueryTest
|
|||
throw new ISE("result[%s] was type[%s]!? Expected it to be numerical", i, types[i].getType());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result[i] = NullHandling.defaultValueForType(types[i].getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
assertResultsEquals(filename, input.expectedResults, results.results);
|
||||
|
||||
assertResultsValid(filename, input.expectedResults, results);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue