[
https://issues.apache.org/jira/browse/TAJO-1426?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14373085#comment-14373085
]
ASF GitHub Bot commented on TAJO-1426:
--------------------------------------
Github user navis commented on a diff in the pull request:
https://github.com/apache/tajo/pull/441#discussion_r26897619
--- Diff: tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java ---
@@ -317,6 +333,60 @@ public ResultSet executeQuery() throws Exception {
return executeFile(getMethodName() + ".sql");
}
+ private volatile Description current;
+
+ @Rule
+ public TestRule watcher = new TestWatcher() {
+ @Override
+ protected void starting(Description description) {
+ QueryTestCaseBase.this.current = description;
+ }
+ };
+
+ @Target({ElementType.METHOD})
+ @Retention(RetentionPolicy.RUNTIME)
+ protected static @interface SimpleTest {
+ String[] queries();
+ String[] cleanupTables() default {};
+ }
+
+ protected void runSimpleTests() throws Exception {
+ String methodName = getMethodName();
+ Method method = current.getTestClass().getMethod(methodName);
+ SimpleTest annotation = method.getAnnotation(SimpleTest.class);
+ if (annotation == null) {
+ throw new IllegalStateException("Cannot find test annotation");
+ }
+ String[] queries = annotation.queries();
+ try {
+ for (int i = 0; i < queries.length; i++) {
+ ResultSet result = client.executeQueryAndGetResult(queries[i]);
+ Path resultPath = StorageUtil.concatPath(
+ currentResultPath, methodName + "." + String.valueOf(i + 1) +
".result");
+ if (currentResultFS.exists(resultPath)) {
+ assertEquals("Result Verification",
+
FileUtil.readTextFromStream(currentResultFS.open(resultPath)),
resultSetToString(result).trim());
+ } else if (!isNull(result)) {
+ FileUtil.writeTextToStream(resultSetToString(result).trim(),
currentResultFS.create(resultPath));
--- End diff --
In the first patch, it was just else { FileUtils.write..} ,which is for
creating gold file for new test. In hive there are option
(-Dtest.overwrite=true) but I couldn't find something like that in Tajo. So
just I've made one if there is no result file expected.
Adding "isNull" to the clause in next patch was because I though some DDL
queries can be used in here, which has no output result. For example,
SimpleTest(queres= {"create table x ...", "select * from x.."}, cleanup="x")
> Support "explain physical" to get physical plan
> -----------------------------------------------
>
> Key: TAJO-1426
> URL: https://issues.apache.org/jira/browse/TAJO-1426
> Project: Tajo
> Issue Type: Improvement
> Reporter: Navis
> Assignee: Navis
> Priority: Minor
>
> Inconvenient to see that in log file.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)