You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2015/09/07 09:07:47 UTC
[3/8] tajo git commit: TAJO-1816: Refactor SQL parser tests.
TAJO-1816: Refactor SQL parser tests.
Closes #731
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/89c140c0
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/89c140c0
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/89c140c0
Branch: refs/heads/branch-0.11.0
Commit: 89c140c05c34b5ca7c64682e43f8c51bb04bb525
Parents: 0f5d97a
Author: Hyunsik Choi <hy...@apache.org>
Authored: Mon Sep 7 15:01:50 2015 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Mon Sep 7 15:07:30 2015 +0900
----------------------------------------------------------------------
CHANGES | 2 +
.../java/org/apache/tajo/util/FileUtil.java | 2 +-
.../tajo/engine/parser/TestSQLAnalyzer.java | 897 +++----------------
.../alter_table_add_partition_1.sql | 1 +
.../alter_table_add_partition_2.sql | 1 +
.../alter_table_add_partition_3.sql | 2 +
.../alter_table_add_partition_4.sql | 1 +
.../alter_table_add_partition_5.sql | 1 +
.../alter_table_drop_partition_1.sql | 1 +
.../alter_table_drop_partition_2.sql | 1 +
.../alter_table_drop_partition_3.sql | 1 +
.../alter_table_drop_partition_4.sql | 1 +
.../alter_table_set_property_1.sql | 1 +
.../alter_table_set_property_2.sql | 1 +
.../alter_table_set_property_3.sql | 1 +
.../TestSQLAnalyzer/create_table_like_1.sql | 1 +
.../create_table_partition_by_column.sql | 4 +
.../create_table_partition_by_hash_1.sql | 3 +
.../create_table_partition_by_hash_2.sql | 7 +
.../create_table_partition_by_list.sql | 8 +
.../create_table_partition_by_range.sql | 9 +
.../TestSQLAnalyzer/exprs/value_expressions.txt | 29 +
.../TestSQLAnalyzer/positive/asterisk_1.sql | 1 +
.../TestSQLAnalyzer/positive/asterisk_2.sql | 1 +
.../TestSQLAnalyzer/positive/asterisk_3.sql | 1 +
.../TestSQLAnalyzer/positive/asterisk_4.sql | 1 +
.../create_partitioned_table_as_select.sql | 17 +
.../TestSQLAnalyzer/positive/create_table_1.sql | 1 +
.../positive/create_table_10.sql | 1 +
.../positive/create_table_11.sql | 3 +
.../positive/create_table_12.sql | 3 +
.../TestSQLAnalyzer/positive/create_table_2.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_3.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_4.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_5.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_6.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_7.sql | 1 +
.../TestSQLAnalyzer/positive/create_table_8.sql | 48 +
.../TestSQLAnalyzer/positive/create_table_9.sql | 1 +
.../positive/create_table_like_1.sql | 1 +
.../TestSQLAnalyzer/positive/drop_table.sql | 1 +
.../positive/exists_predicate_1.sql | 1 +
.../positive/exists_predicate_2.sql | 1 +
.../TestSQLAnalyzer/positive/groupby_1.sql | 1 +
.../TestSQLAnalyzer/positive/groupby_2.sql | 1 +
.../TestSQLAnalyzer/positive/groupby_3.sql | 1 +
.../TestSQLAnalyzer/positive/groupby_4.sql | 1 +
.../TestSQLAnalyzer/positive/groupby_5.sql | 1 +
.../TestSQLAnalyzer/positive/in_subquery_1.sql | 1 +
.../TestSQLAnalyzer/positive/in_subquery_2.sql | 1 +
.../positive/insert_into_select_1.sql | 1 +
.../positive/insert_into_select_2.sql | 1 +
.../positive/insert_into_select_3.sql | 1 +
.../positive/insert_overwrite_into_select_1.sql | 1 +
.../positive/insert_overwrite_into_select_2.sql | 1 +
.../positive/insert_overwrite_into_select_3.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_1.sql | 1 +
.../TestSQLAnalyzer/positive/join_10.sql | 1 +
.../TestSQLAnalyzer/positive/join_11.sql | 1 +
.../TestSQLAnalyzer/positive/join_12.sql | 1 +
.../TestSQLAnalyzer/positive/join_13.sql | 13 +
.../TestSQLAnalyzer/positive/join_14.sql | 1 +
.../TestSQLAnalyzer/positive/join_15.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_2.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_3.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_4.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_5.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_6.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_7.sql | 1 +
.../queries/TestSQLAnalyzer/positive/join_8.sql | 13 +
.../queries/TestSQLAnalyzer/positive/join_9.sql | 5 +
.../TestSQLAnalyzer/positive/select_1.sql | 1 +
.../TestSQLAnalyzer/positive/select_10.sql | 5 +
.../TestSQLAnalyzer/positive/select_11.sql | 6 +
.../TestSQLAnalyzer/positive/select_13.sql | 2 +
.../TestSQLAnalyzer/positive/select_14.sql | 2 +
.../TestSQLAnalyzer/positive/select_15.sql | 1 +
.../TestSQLAnalyzer/positive/select_2.sql | 1 +
.../TestSQLAnalyzer/positive/select_3.sql | 1 +
.../TestSQLAnalyzer/positive/select_4.sql | 1 +
.../TestSQLAnalyzer/positive/select_5.sql | 1 +
.../TestSQLAnalyzer/positive/select_6.sql | 1 +
.../TestSQLAnalyzer/positive/select_7.sql | 1 +
.../TestSQLAnalyzer/positive/select_8.sql | 1 +
.../TestSQLAnalyzer/positive/select_9.sql | 4 +
.../queries/TestSQLAnalyzer/positive/set_1.sql | 1 +
.../queries/TestSQLAnalyzer/positive/set_2.sql | 1 +
.../queries/TestSQLAnalyzer/positive/set_3.sql | 1 +
.../queries/TestSQLAnalyzer/positive/set_4.sql | 36 +
.../positive/table_subquery1.sql | 19 +
.../positive/table_subquery2.sql | 21 +
.../default/alter_table_add_partition_1.sql | 1 -
.../default/alter_table_add_partition_2.sql | 1 -
.../default/alter_table_add_partition_3.sql | 2 -
.../default/alter_table_add_partition_4.sql | 1 -
.../default/alter_table_add_partition_5.sql | 1 -
.../default/alter_table_drop_partition_1.sql | 1 -
.../default/alter_table_drop_partition_2.sql | 1 -
.../default/alter_table_drop_partition_3.sql | 1 -
.../default/alter_table_drop_partition_4.sql | 1 -
.../default/alter_table_set_property_1.sql | 1 -
.../default/alter_table_set_property_2.sql | 1 -
.../default/alter_table_set_property_3.sql | 1 -
.../resources/queries/default/asterisk_1.sql | 1 -
.../resources/queries/default/asterisk_2.sql | 1 -
.../resources/queries/default/asterisk_3.sql | 1 -
.../resources/queries/default/asterisk_4.sql | 1 -
.../create_partitioned_table_as_select.sql | 17 -
.../queries/default/create_table_1.hiveql | 1 -
.../queries/default/create_table_1.sql | 1 -
.../queries/default/create_table_10.sql | 1 -
.../queries/default/create_table_11.hiveql | 3 -
.../queries/default/create_table_11.sql | 3 -
.../queries/default/create_table_12.hiveql | 4 -
.../queries/default/create_table_12.sql | 3 -
.../queries/default/create_table_2.hiveql | 1 -
.../queries/default/create_table_2.sql | 1 -
.../queries/default/create_table_3.sql | 1 -
.../queries/default/create_table_4.sql | 1 -
.../queries/default/create_table_5.sql | 1 -
.../queries/default/create_table_6.sql | 1 -
.../queries/default/create_table_7.sql | 1 -
.../queries/default/create_table_8.sql | 48 -
.../queries/default/create_table_9.sql | 1 -
.../queries/default/create_table_like_1.sql | 1 -
.../create_table_partition_by_column.sql | 4 -
.../create_table_partition_by_hash_1.sql | 3 -
.../create_table_partition_by_hash_2.sql | 7 -
.../default/create_table_partition_by_list.sql | 8 -
.../default/create_table_partition_by_range.sql | 9 -
.../resources/queries/default/drop_table.sql | 1 -
.../queries/default/exists_predicate_1.sql | 1 -
.../queries/default/exists_predicate_2.sql | 1 -
.../resources/queries/default/groupby_1.sql | 1 -
.../resources/queries/default/groupby_2.sql | 1 -
.../resources/queries/default/groupby_3.sql | 1 -
.../resources/queries/default/groupby_4.sql | 1 -
.../resources/queries/default/groupby_5.sql | 1 -
.../resources/queries/default/in_subquery_1.sql | 1 -
.../resources/queries/default/in_subquery_2.sql | 1 -
.../queries/default/insert_into_select_1.sql | 1 -
.../queries/default/insert_into_select_2.sql | 1 -
.../queries/default/insert_into_select_3.sql | 1 -
.../default/insert_overwrite_into_select_1.sql | 1 -
.../insert_overwrite_into_select_2.hiveql | 1 -
.../default/insert_overwrite_into_select_2.sql | 1 -
.../default/insert_overwrite_into_select_3.sql | 1 -
.../test/resources/queries/default/join_1.sql | 1 -
.../test/resources/queries/default/join_10.sql | 1 -
.../test/resources/queries/default/join_11.sql | 1 -
.../test/resources/queries/default/join_12.sql | 1 -
.../test/resources/queries/default/join_13.sql | 13 -
.../test/resources/queries/default/join_14.sql | 1 -
.../resources/queries/default/join_15.hiveql | 1 -
.../test/resources/queries/default/join_15.sql | 1 -
.../test/resources/queries/default/join_2.sql | 1 -
.../test/resources/queries/default/join_3.sql | 1 -
.../test/resources/queries/default/join_4.sql | 1 -
.../test/resources/queries/default/join_5.sql | 1 -
.../test/resources/queries/default/join_6.sql | 1 -
.../test/resources/queries/default/join_7.sql | 1 -
.../test/resources/queries/default/join_8.sql | 13 -
.../test/resources/queries/default/join_9.sql | 5 -
.../test/resources/queries/default/select_1.sql | 1 -
.../resources/queries/default/select_10.hiveql | 5 -
.../resources/queries/default/select_10.sql | 5 -
.../resources/queries/default/select_11.hiveql | 4 -
.../resources/queries/default/select_11.sql | 6 -
.../resources/queries/default/select_12.hiveql | 3 -
.../resources/queries/default/select_13.hiveql | 2 -
.../resources/queries/default/select_13.sql | 2 -
.../resources/queries/default/select_14.sql | 2 -
.../resources/queries/default/select_15.hiveql | 1 -
.../resources/queries/default/select_15.sql | 1 -
.../test/resources/queries/default/select_2.sql | 1 -
.../test/resources/queries/default/select_3.sql | 1 -
.../test/resources/queries/default/select_4.sql | 1 -
.../test/resources/queries/default/select_5.sql | 1 -
.../test/resources/queries/default/select_6.sql | 1 -
.../test/resources/queries/default/select_7.sql | 1 -
.../test/resources/queries/default/select_8.sql | 1 -
.../resources/queries/default/select_9.hiveql | 4 -
.../test/resources/queries/default/select_9.sql | 4 -
.../test/resources/queries/default/set_1.sql | 1 -
.../test/resources/queries/default/set_2.sql | 1 -
.../test/resources/queries/default/set_3.sql | 1 -
.../test/resources/queries/default/set_4.sql | 36 -
.../queries/default/table_subquery1.sql | 19 -
.../queries/default/table_subquery2.sql | 21 -
.../resources/queries/default/union_1.hiveql | 14 -
.../alter_table_add_partition_1.result | 30 +
.../alter_table_add_partition_2.result | 31 +
.../alter_table_add_partition_3.result | 40 +
.../alter_table_add_partition_4.result | 21 +
.../alter_table_add_partition_5.result | 21 +
.../alter_table_drop_partition_1.result | 30 +
.../alter_table_drop_partition_2.result | 39 +
.../alter_table_drop_partition_3.result | 21 +
.../alter_table_drop_partition_4.result | 21 +
.../alter_table_set_property_1.result | 11 +
.../alter_table_set_property_2.result | 11 +
.../alter_table_set_property_3.result | 12 +
.../TestSQLAnalyzer/create_table_like_1.result | 7 +
.../create_table_partition_by_column.result | 39 +
.../create_table_partition_by_hash_1.result | 32 +
.../create_table_partition_by_hash_2.result | 38 +
.../create_table_partition_by_list.result | 65 ++
.../create_table_partition_by_range.result | 55 ++
.../apache/tajo/storage/TablespaceManager.java | 9 +-
209 files changed, 998 insertions(+), 1100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 86252c3..bb04120 100644
--- a/CHANGES
+++ b/CHANGES
@@ -34,6 +34,8 @@ Release 0.11.0 - unreleased
IMPROVEMENT
+ TAJO-1816: Refactor SQL parser tests. (hyunsik)
+
TAJO-1738: Improve off-heap RowBlock. (jinho)
TAJO-1810: Remove QueryMasterTask cache immediately, if it stored to
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-common/src/main/java/org/apache/tajo/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/util/FileUtil.java b/tajo-common/src/main/java/org/apache/tajo/util/FileUtil.java
index 5216eb8..2eff9c8 100644
--- a/tajo-common/src/main/java/org/apache/tajo/util/FileUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/util/FileUtil.java
@@ -96,7 +96,7 @@ public class FileUtil {
if (stream != null) {
return readTextFromStream(stream);
} else {
- return null;
+ throw new FileNotFoundException(resource);
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/java/org/apache/tajo/engine/parser/TestSQLAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/parser/TestSQLAnalyzer.java b/tajo-core-tests/src/test/java/org/apache/tajo/engine/parser/TestSQLAnalyzer.java
index e9a9305..553aea4 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/parser/TestSQLAnalyzer.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/parser/TestSQLAnalyzer.java
@@ -18,805 +18,192 @@
package org.apache.tajo.engine.parser;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Lists;
import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.BailErrorStrategy;
import org.antlr.v4.runtime.CommonTokenStream;
-import org.apache.tajo.algebra.*;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.tajo.algebra.Expr;
+import org.apache.tajo.annotation.Nullable;
+import org.apache.tajo.conf.TajoConf;
import org.apache.tajo.engine.parser.SQLParser.SqlContext;
+import org.apache.tajo.storage.StorageUtil;
import org.apache.tajo.util.FileUtil;
+import org.apache.tajo.util.Pair;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestName;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Collection;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static com.google.common.collect.Collections2.filter;
+import static com.google.common.collect.Collections2.transform;
+import static org.junit.Assert.*;
/**
- * This unit tests uses a number of query files located in tajo/tajo-core/queries.
- * So, you must set tajo/tajo-core/ as the working directory.
+ * This class verifies SQLAnalyzer.
*/
public class TestSQLAnalyzer {
+ @Rule public TestName name = new TestName();
public static Expr parseQuery(String sql) {
ANTLRInputStream input = new ANTLRInputStream(sql);
SQLLexer lexer = new SQLLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
+
SQLParser parser = new SQLParser(tokens);
+ parser.setErrorHandler(new BailErrorStrategy());
parser.setBuildParseTree(true);
+
SQLAnalyzer visitor = new SQLAnalyzer();
SqlContext context = parser.sql();
return visitor.visitSql(context);
}
- public void assertParseResult(String sqlFileName, String resultFileName) throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/TestSQLAnalyzer/" + sqlFileName);
- String result = FileUtil.readTextFileFromResource("results/TestSQLAnalyzer/" + resultFileName);
-
- Expr expr = parseQuery(sql);
- assertEquals(result.trim(), expr.toJson().trim());
- }
-
-
- @Test
- public void testSelect1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/select_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSelect2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/select_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSelect3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/select_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSelect4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/select_4.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSelect5() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/select_5.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testAsterisk1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/asterisk_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testAsterisk2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/asterisk_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testAsterisk3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/asterisk_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testAsterisk4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/asterisk_4.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testGroupby1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/groupby_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_4.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin5() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_5.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin6() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_6.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin7() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_7.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin8() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_8.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin9() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_9.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin10() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_10.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testJoin11() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/join_11.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSet1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/set_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSet2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/set_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSet3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/set_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testSet4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/set_4.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testDropTable() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/drop_table.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_4.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable5() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_5.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable6() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_6.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable7() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_7.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable8() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_8.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable9() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_9.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTable10() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_10.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testCreateTableLike1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_like_1.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertEquals("orig_name", createTable.getLikeParentTableName());
- }
-
- @Test
- public void testCreateTablePartitionByHash1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_partition_by_hash_1.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertTrue(createTable.hasPartition());
- assertEquals(CreateTable.PartitionType.HASH, createTable.getPartitionMethod().getPartitionType());
- CreateTable.HashPartition hashPartition = createTable.getPartitionMethod();
- assertEquals("col1", hashPartition.getColumns()[0].getCanonicalName());
- assertTrue(hashPartition.hasQuantifier());
- }
-
- @Test
- public void testCreateTablePartitionByHash2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_partition_by_hash_2.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertTrue(createTable.hasPartition());
- assertEquals(CreateTable.PartitionType.HASH, createTable.getPartitionMethod().getPartitionType());
- CreateTable.HashPartition hashPartition = createTable.getPartitionMethod();
- assertEquals("col1", hashPartition.getColumns()[0].getCanonicalName());
- assertTrue(hashPartition.hasSpecifiers());
- assertEquals(3, hashPartition.getSpecifiers().size());
- }
-
- @Test
- public void testCreateTablePartitionByRange() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_partition_by_range.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertTrue(createTable.hasPartition());
- assertEquals(CreateTable.PartitionType.RANGE, createTable.getPartitionMethod().getPartitionType());
- CreateTable.RangePartition rangePartition = createTable.getPartitionMethod();
- assertEquals("col1", rangePartition.getColumns()[0].getCanonicalName());
- assertEquals(3, rangePartition.getSpecifiers().size());
- }
-
- @Test
- public void testCreateTablePartitionByList() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_partition_by_list.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertTrue(createTable.hasPartition());
- assertEquals(CreateTable.PartitionType.LIST, createTable.getPartitionMethod().getPartitionType());
- CreateTable.ListPartition listPartition = createTable.getPartitionMethod();
- assertEquals("col1", listPartition.getColumns()[0].getCanonicalName());
- assertEquals(2, listPartition.getSpecifiers().size());
- Iterator<CreateTable.ListPartitionSpecifier> iterator = listPartition.getSpecifiers().iterator();
- CreateTable.ListPartitionSpecifier specifier = iterator.next();
- LiteralValue value1 = (LiteralValue) specifier.getValueList().getValues()[0];
- LiteralValue value2 = (LiteralValue) specifier.getValueList().getValues()[1];
- assertEquals("Seoul", value1.getValue());
- assertEquals("서울", value2.getValue());
-
- specifier = iterator.next();
- value1 = (LiteralValue) specifier.getValueList().getValues()[0];
- value2 = (LiteralValue) specifier.getValueList().getValues()[1];
- assertEquals("Busan", value1.getValue());
- assertEquals("부산", value2.getValue());
- }
-
- @Test
- public void testCreateTablePartitionByColumn() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/create_table_partition_by_column.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.CreateTable, expr.getType());
- CreateTable createTable = (CreateTable) expr;
- assertTrue(createTable.hasPartition());
- assertEquals(CreateTable.PartitionType.COLUMN, createTable.getPartitionMethod().getPartitionType());
- CreateTable.ColumnPartition columnPartition = createTable.getPartitionMethod();
- assertEquals(3, columnPartition.getColumns().length);
- assertEquals("col3", columnPartition.getColumns()[0].getColumnName());
- assertEquals("col4", columnPartition.getColumns()[1].getColumnName());
- assertEquals("col5", columnPartition.getColumns()[2].getColumnName());
- }
-
- @Test
- public void testAlterTableAddPartition1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_add_partition_1.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.ADD_PARTITION);
- assertEquals(2, alterTable.getColumns().length);
- assertEquals(2, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- assertEquals("col2", alterTable.getColumns()[1].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("1", value1.getValue());
- LiteralValue value2 = (LiteralValue)alterTable.getValues()[1];
- assertEquals("2", value2.getValue());
- assertFalse(alterTable.isIfNotExists());
- }
-
- @Test
- public void testAlterTableAddPartition2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_add_partition_2.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.ADD_PARTITION);
- assertEquals(2, alterTable.getColumns().length);
- assertEquals(2, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- assertEquals("col2", alterTable.getColumns()[1].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("1", value1.getValue());
- LiteralValue value2 = (LiteralValue)alterTable.getValues()[1];
- assertEquals("2", value2.getValue());
- assertEquals(alterTable.getLocation(), "hdfs://xxx.com/warehouse/table1/col1=1/col2=2");
- assertFalse(alterTable.isIfNotExists());
- }
-
- @Test
- public void testAlterTableAddPartition3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_add_partition_3.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.ADD_PARTITION);
- assertEquals(3, alterTable.getColumns().length);
- assertEquals(3, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- assertEquals("col2", alterTable.getColumns()[1].getName());
- assertEquals("col3", alterTable.getColumns()[2].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("2015", value1.getValue());
- LiteralValue value2 = (LiteralValue)alterTable.getValues()[1];
- assertEquals("01", value2.getValue());
- LiteralValue value3 = (LiteralValue)alterTable.getValues()[2];
- assertEquals("11", value3.getValue());
- assertEquals(alterTable.getLocation(), "hdfs://xxx.com/warehouse/table1/col1=2015/col2=01/col3=11");
- assertFalse(alterTable.isIfNotExists());
- }
-
- @Test
- public void testAlterTableAddPartition4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_add_partition_4.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.ADD_PARTITION);
- assertEquals(1, alterTable.getColumns().length);
- assertEquals(1, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("TAJO", value1.getValue());
- assertFalse(alterTable.isIfNotExists());
- }
-
- @Test
- public void testAlterTableAddPartition5() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_add_partition_5.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.ADD_PARTITION);
- assertEquals(1, alterTable.getColumns().length);
- assertEquals(1, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("TAJO", value1.getValue());
- assertTrue(alterTable.isIfNotExists());
- }
-
- @Test
- public void testAlterTableDropPartition1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_drop_partition_1.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.DROP_PARTITION);
- assertEquals(2, alterTable.getColumns().length);
- assertEquals(2, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- assertEquals("col2", alterTable.getColumns()[1].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("1", value1.getValue());
- LiteralValue value2 = (LiteralValue)alterTable.getValues()[1];
- assertEquals("2", value2.getValue());
- assertFalse(alterTable.isPurge());
- assertFalse(alterTable.isIfExists());
- }
-
- @Test
- public void testAlterTableDropPartition2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_drop_partition_2.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.DROP_PARTITION);
- assertEquals(3, alterTable.getColumns().length);
- assertEquals(3, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- assertEquals("col2", alterTable.getColumns()[1].getName());
- assertEquals("col3", alterTable.getColumns()[2].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("2015", value1.getValue());
- LiteralValue value2 = (LiteralValue)alterTable.getValues()[1];
- assertEquals("01", value2.getValue());
- LiteralValue value3 = (LiteralValue)alterTable.getValues()[2];
- assertEquals("11", value3.getValue());
- assertFalse(alterTable.isPurge());
- assertFalse(alterTable.isIfExists());
- }
-
- @Test
- public void testAlterTableDropPartition3() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_drop_partition_3.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.DROP_PARTITION);
- assertEquals(1, alterTable.getColumns().length);
- assertEquals(1, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("TAJO", value1.getValue());
- assertTrue(alterTable.isPurge());
- assertFalse(alterTable.isIfExists());
- }
-
- @Test
- public void testAlterTableDropPartition4() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_drop_partition_4.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.DROP_PARTITION);
- assertEquals(1, alterTable.getColumns().length);
- assertEquals(1, alterTable.getValues().length);
- assertEquals("col1", alterTable.getColumns()[0].getName());
- LiteralValue value1 = (LiteralValue)alterTable.getValues()[0];
- assertEquals("TAJO", value1.getValue());
- assertTrue(alterTable.isPurge());
- assertTrue(alterTable.isIfExists());
- }
-
- @Test
- public void testAlterTableSetProperty1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_set_property_1.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.SET_PROPERTY);
- assertTrue(alterTable.hasParams());
- assertTrue(alterTable.getParams().containsKey("timezone"));
- assertEquals("GMT-7", alterTable.getParams().get("timezone"));
- }
-
- @Test
- public void testAlterTableSetProperty2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_set_property_2.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.SET_PROPERTY);
- assertTrue(alterTable.hasParams());
- assertTrue(alterTable.getParams().containsKey("text.delimiter"));
- assertEquals("&", alterTable.getParams().get("text.delimiter"));
- }
-
- @Test
- public void testAlterTableSetProperty3() throws IOException {
- // update multiple table properties with a single 'SET PROPERTY' sql
- String sql = FileUtil.readTextFileFromResource("queries/default/alter_table_set_property_3.sql");
- Expr expr = parseQuery(sql);
- assertEquals(OpType.AlterTable, expr.getType());
- AlterTable alterTable = (AlterTable)expr;
- assertEquals(alterTable.getAlterTableOpType(), AlterTableOpType.SET_PROPERTY);
- assertTrue(alterTable.hasParams());
- assertTrue(alterTable.getParams().containsKey("compression.type"));
- assertEquals("RECORD", alterTable.getParams().get("compression.type"));
- assertTrue(alterTable.getParams().containsKey("compression.codec"));
- assertEquals("org.apache.hadoop.io.compress.SnappyCodec", alterTable.getParams().get("compression.codec"));
- }
-
- @Test
- public void testTableSubQuery1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/table_subquery1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testTableSubQuery2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/table_subquery2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testInSubquery1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/in_subquery_1.sql");
- parseQuery(sql);
- }
+ public Collection<File> getResourceFiles(String subdir) throws URISyntaxException, IOException {
+ URL uri = ClassLoader.getSystemResource("queries/TestSQLAnalyzer");
+ Path positiveQueryDir = StorageUtil.concatPath(new Path(uri.toURI()), subdir);
+ FileSystem fs = positiveQueryDir.getFileSystem(new TajoConf());
- @Test
- public void testInSubquery2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/in_subquery_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testExistsPredicate1() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/exists_predicate_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testExistsPredicate2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/exists_predicate_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testInsertIntoTable() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_into_select_1.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testInsertIntoLocation() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_into_select_2.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testInsertIntoTable2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_into_select_3.sql");
- parseQuery(sql);
- }
-
- @Test
- public void testInsertOverwriteIntoTable() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_overwrite_into_select_1.sql");
- parseQuery(sql);
- }
+ if (!fs.exists(positiveQueryDir)) {
+ throw new IOException("Cannot find " + positiveQueryDir);
+ }
- @Test
- public void testInsertOverwriteIntoLocation() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_overwrite_into_select_2.sql");
- parseQuery(sql);
+ // get only files
+ Collection<FileStatus> files = filter(Lists.newArrayList(fs.listStatus(positiveQueryDir)),
+ new Predicate<FileStatus>() {
+ @Override
+ public boolean apply(@Nullable FileStatus input) {
+ return input.isFile();
+ }
+ }
+ );
+
+ // transform FileStatus into File
+ return transform(files, new Function<FileStatus, File>() {
+ @Override
+ public File apply(@Nullable FileStatus fileStatus) {
+ return new File(URI.create(fileStatus.getPath().toString()));
+ }
+ });
+ }
+
+ /**
+ * Return a pair of file name and SQL query
+ *
+ * @return a pair of file name and SQL query
+ * @throws IOException
+ * @throws URISyntaxException
+ */
+ public Collection<Pair<String, String>> getFileContents(String subdir) throws IOException, URISyntaxException {
+ return transform(getResourceFiles(subdir), new Function<File, Pair<String, String>>() {
+ @Override
+ public Pair<String, String> apply(@Nullable File file) {
+ try {
+ return new Pair<>(file.getName(), FileUtil.readTextFile(file));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+
+ /**
+ * In order to add more unit tests, please add SQL files into resources/results/TestSQLAnalyzer/positive.
+ * This test just checkes if SQL statements are parsed successfully.
+ *
+ * @throws IOException
+ * @throws URISyntaxException
+ */
+ @Test
+ public void testPositiveTests() throws IOException, URISyntaxException {
+ for (Pair<String, String> pair : getFileContents("positive")) {
+ try {
+ assertNotNull(parseQuery(pair.getSecond()));
+ System.out.println(pair.getFirst() + " test passed...");
+ } catch (Throwable t) {
+ fail("Parsing '" + pair.getFirst() + "' failed, its cause: " + t.getMessage());
+ }
+ }
}
- @Test
- public void testInsertOverwriteIntoTable2() throws IOException {
- String sql = FileUtil.readTextFileFromResource("queries/default/insert_overwrite_into_select_3.sql");
- parseQuery(sql);
+ /**
+ * In order to add more unit tests, add a SQL file including a SQL statement
+ * into the directory resources/queries/TestSQLAnalyzer
+ * and its generated algebraic expression formatted by json into resources/results/TestSQLAnalyzer.
+ * Each result file name must be the same to its SQL file.
+ *
+ * @throws IOException
+ * @throws URISyntaxException
+ */
+ @Test
+ public void testGeneratedAlgebras() throws IOException, URISyntaxException {
+ for (Pair<String, String> pair : getFileContents(".")) {
+ Expr expr = parseQuery(pair.getSecond());
+
+ String expectedResult = null;
+ String fileName = null;
+ try {
+ fileName = pair.getFirst().split("\\.")[0];
+ expectedResult = FileUtil.readTextFileFromResource("results/TestSQLAnalyzer/" + fileName + ".result");
+ } catch (FileNotFoundException ioe) {
+ expectedResult = "";
+ } catch (Throwable t) {
+ fail(t.getMessage());
+ }
+
+ assertEquals(pair.getFirst() + " is different from " + fileName + ".result",
+ expectedResult.trim(), expr.toJson().trim());
+ System.out.println(pair.getFirst() + " test passed..");
+ }
}
- static String[] exprs = {
- "1 + 2", // 0
- "3 - 4", // 1
- "5 * 6", // 2
- "7 / 8", // 3
- "10 % 2", // 4
- "1 * 2 > 3 / 4", // 5
- "1 * 2 < 3 / 4", // 6
- "1 * 2 = 3 / 4", // 7
- "1 * 2 != 3 / 4", // 8
- "1 * 2 <> 3 / 4", // 9
- "gender in ('male', 'female')", // 10
- "gender not in ('male', 'female')", // 11
- "score > 90 and age < 20", // 12
- "score > 90 and age < 20 and name != 'hyunsik'", // 13
- "score > 90 or age < 20", // 14
- "score > 90 or age < 20 and name != 'hyunsik'", // 15
- "((a+3 > 1) or 1=1) and (3 != (abc + 4) and type in (3,4))", // 16
- "3", // 17
- "1.2", // 18
- "sum(age)", // 19
- "now()", // 20
- "not (90 > 100)", // 21
- "type like '%top'", // 22
- "type not like 'top%'", // 23
- "col = 'value'", // 24
- "col is null", // 25
- "col is not null", // 26
- "col = null", // 27
- "col != null", // 38
- };
-
- public static Expr parseExpr(String sql) {
+ private static Expr parseExpr(String sql) {
ANTLRInputStream input = new ANTLRInputStream(sql);
SQLLexer lexer = new SQLLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
+
SQLParser parser = new SQLParser(tokens);
+ parser.setErrorHandler(new BailErrorStrategy());
parser.setBuildParseTree(true);
+
SQLAnalyzer visitor = new SQLAnalyzer();
SQLParser.Value_expressionContext context = parser.value_expression();
return visitor.visitValue_expression(context);
}
+ /**
+ * In order to add more unit tests, add text files including SQL expressions
+ * into the directory resources/queries/TestSQLAnalyzer/exprs.
+ *
+ * @throws IOException
+ * @throws URISyntaxException
+ */
@Test
- public void testExprs() {
- for (int i = 0; i < exprs.length; i++) {
- parseExpr(exprs[i]);
+ public void testExprs() throws IOException, URISyntaxException {
+ for (Pair<String, String> pair : getFileContents("exprs")) {
+ testExprs(pair.getFirst(), pair.getSecond());
+ System.out.println(pair.getFirst() + " test passed..");
}
}
- @Test
- public void windowFunction1() throws IOException {
- assertParseResult("window1.sql", "window1.result");
- }
-
- @Test
- public void windowFunction2() throws IOException {
- assertParseResult("window2.sql", "window2.result");
- }
-
- @Test
- public void windowFunction3() throws IOException {
- assertParseResult("window3.sql", "window3.result");
- }
-
- @Test
- public void windowFunction4() throws IOException {
- assertParseResult("window4.sql", "window4.result");
- }
-
- @Test
- public void windowFunction5() throws IOException {
- assertParseResult("window5.sql", "window5.result");
- }
-
- @Test
- public void windowFunction6() throws IOException {
- assertParseResult("window6.sql", "window6.result");
- }
-
- @Test
- public void windowFunction7() throws IOException {
- assertParseResult("window7.sql", "window7.result");
- }
-
- @Test
- public void windowFunction8() throws IOException {
- assertParseResult("window8.sql", "window8.result");
- }
-
- @Test
- public void windowFunction9() throws IOException {
- assertParseResult("window9.sql", "window9.result");
- }
-
- @Test
- public void testSetCatalog1() throws IOException {
- assertParseResult("setcatalog1.sql", "setcatalog1.result");
- }
-
- @Test
- public void testSetCatalog2() throws IOException {
- assertParseResult("setcatalog2.sql", "setcatalog2.result");
- }
-
- @Test
- public void testTimezone1() throws IOException {
- assertParseResult("settimezone1.sql", "settimezone1.result");
- }
-
- @Test
- public void testTimezone2() throws IOException {
- assertParseResult("settimezone2.sql", "settimezone2.result");
- }
-
- @Test
- public void testTimezone3() throws IOException {
- assertParseResult("settimezone3.sql", "settimezone3.result");
- }
-
- @Test
- public void testSetSession1() throws IOException {
- assertParseResult("setsession1.sql", "setsession1.result");
- }
-
- @Test
- public void testSetSession2() throws IOException {
- assertParseResult("setsession2.sql", "setsession2.result");
- }
-
- @Test
- public void testSetSession3() throws IOException {
- assertParseResult("setsession3.sql", "setsession3.result");
- }
-
- @Test
- public void testSetSession4() throws IOException {
- assertParseResult("setsession4.sql", "setsession4.result");
- }
-
- @Test
- public void testSetSession5() throws IOException {
- assertParseResult("setsession5.sql", "setsession5.result");
- }
-
- @Test
- public void testSetSession6() throws IOException {
- assertParseResult("setsession6.sql", "setsession6.result");
- }
-
- @Test
- public void testSetSession7() throws IOException {
- assertParseResult("setsession7.sql", "setsession7.result");
- }
-
- @Test
- public void testCreateTableWithNested1() throws IOException {
- assertParseResult("create_table_nested_1.sql", "create_table_nested_1.result");
- }
-
- @Test
- public void testCreateTableWithNested2() throws IOException {
- assertParseResult("create_table_nested_2.sql", "create_table_nested_2.result");
- }
-
- @Test
- public void testCreateTableWithMapType1() throws IOException {
- // primitive key value map
- assertParseResult("create_table_maptype_1.sql", "create_table_maptype_1.result");
- }
-
- @Test
- public void testCreateTableWithMapType2() throws IOException {
- // primitive key and record value map
- assertParseResult("create_table_maptype_2.sql", "create_table_maptype_2.result");
- }
-
- @Test
- public void testCreateTableWithMapType3() throws IOException {
- // primitive key and nexted record value map
- assertParseResult("create_table_maptype_3.sql", "create_table_maptype_3.result");
+ private void testExprs(String file, String fileContents) {
+ for (String line : fileContents.split("\n")) {
+ try {
+ assertNotNull(parseExpr(line));
+ } catch (Throwable t) {
+ fail(line + " in " + file + " failed..");
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_1.sql
new file mode 100644
index 0000000..0f91b68
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_1.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 ADD PARTITION (col1 = 1 , col2 = 2)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_2.sql
new file mode 100644
index 0000000..ee4df75
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_2.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 ADD PARTITION (col1 = 1 , col2 = 2) LOCATION 'hdfs://xxx.com/warehouse/table1/col1=1/col2=2'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_3.sql
new file mode 100644
index 0000000..79d1426
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_3.sql
@@ -0,0 +1,2 @@
+ALTER TABLE table1 ADD PARTITION (col1 = '2015' , col2 = '01', col3 = '11' )
+LOCATION 'hdfs://xxx.com/warehouse/table1/col1=2015/col2=01/col3=11'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_4.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_4.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_4.sql
new file mode 100644
index 0000000..bc22a14
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_4.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 ADD PARTITION (col1 = 'TAJO' )
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_5.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_5.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_5.sql
new file mode 100644
index 0000000..127d999
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_add_partition_5.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 ADD IF NOT EXISTS PARTITION (col1 = 'TAJO' )
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_1.sql
new file mode 100644
index 0000000..6e2ad7c
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_1.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 DROP PARTITION (col1 = 1 , col2 = 2)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_2.sql
new file mode 100644
index 0000000..5752710
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_2.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 DROP PARTITION (col1 = '2015' , col2 = '01', col3 = '11' )
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_3.sql
new file mode 100644
index 0000000..8a1a6a5
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_3.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 DROP PARTITION (col1 = 'TAJO' ) PURGE
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_4.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_4.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_4.sql
new file mode 100644
index 0000000..44c7977
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_drop_partition_4.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 DROP IF EXISTS PARTITION (col1 = 'TAJO' ) PURGE
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_1.sql
new file mode 100644
index 0000000..ac7aa4d
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_1.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 SET PROPERTY 'timezone' = 'GMT-7'
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_2.sql
new file mode 100644
index 0000000..77df213
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_2.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 SET PROPERTY 'text.delimiter' = '&'
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_3.sql
new file mode 100644
index 0000000..6230a34
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/alter_table_set_property_3.sql
@@ -0,0 +1 @@
+ALTER TABLE table1 SET PROPERTY 'compression.type'='RECORD','compression.codec'='org.apache.hadoop.io.compress.SnappyCodec'
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_like_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_like_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_like_1.sql
new file mode 100644
index 0000000..73f2f46
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_like_1.sql
@@ -0,0 +1 @@
+create table new_table like orig_name;
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_column.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_column.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_column.sql
new file mode 100644
index 0000000..397e7ac
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_column.sql
@@ -0,0 +1,4 @@
+CREATE TABLE sales ( col1 int, col2 int)
+PARTITION BY COLUMN (col3 int, col4 float, col5 text);
+
+
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_1.sql
new file mode 100644
index 0000000..f13225a
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_1.sql
@@ -0,0 +1,3 @@
+CREATE TABLE sales ( col1 int, col2 int)
+PARTITION BY HASH (col1)
+PARTITIONS 2;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_2.sql
new file mode 100644
index 0000000..c8fe3c5
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_hash_2.sql
@@ -0,0 +1,7 @@
+CREATE TABLE sales ( col1 int, col2 int)
+PARTITION BY HASH (col1)
+(
+ PARTITION part1,
+ PARTITION part2,
+ PARTITION part3
+);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_list.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_list.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_list.sql
new file mode 100644
index 0000000..9461e01
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_list.sql
@@ -0,0 +1,8 @@
+CREATE TABLE sales ( col1 int, col2 int)
+PARTITION BY LIST (col1)
+ (
+ PARTITION col1 VALUES ('Seoul', '서울'),
+ PARTITION col2 VALUES ('Busan', '부산')
+ );
+
+
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_range.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_range.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_range.sql
new file mode 100644
index 0000000..65c4fdd
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/create_table_partition_by_range.sql
@@ -0,0 +1,9 @@
+CREATE TABLE sales ( col1 int, col2 int)
+PARTITION BY RANGE (col1)
+ (
+ PARTITION col1 VALUES LESS THAN (2),
+ PARTITION col1 VALUES LESS THAN (5),
+ PARTITION col1 VALUES LESS THAN (MAXVALUE)
+ );
+
+
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/exprs/value_expressions.txt
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/exprs/value_expressions.txt b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/exprs/value_expressions.txt
new file mode 100644
index 0000000..e3623c7
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/exprs/value_expressions.txt
@@ -0,0 +1,29 @@
+1 + 2
+3 - 4
+5 * 6
+7 / 8
+10 % 2
+1 * 2 > 3 / 4
+1 * 2 < 3 / 4
+1 * 2 = 3 / 4
+1 * 2 != 3 / 4
+1 * 2 <> 3 / 4
+gender in ('male', 'female')
+gender not in ('male', 'female')
+score > 90 and age < 20
+score > 90 and age < 20 and name != 'hyunsik'
+score > 90 or age < 20
+score > 90 or age < 20 and name != 'hyunsik'
+((a+3 > 1) or 1=1) and (3 != (abc + 4) and type in (3,4))
+3
+1.2
+sum(age)
+now()
+not (90 > 100)
+type like '%top'
+type not like 'top%'
+col = 'value'
+col is null
+col is not null
+col = null
+col != null
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_1.sql
new file mode 100644
index 0000000..2bbe245
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_1.sql
@@ -0,0 +1 @@
+select * from people
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_2.sql
new file mode 100644
index 0000000..d646044
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_2.sql
@@ -0,0 +1 @@
+select p.*, s.* from people cross join students
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_3.sql
new file mode 100644
index 0000000..1566230
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_3.sql
@@ -0,0 +1 @@
+select * from people cross join students
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_4.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_4.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_4.sql
new file mode 100644
index 0000000..22faf44
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/asterisk_4.sql
@@ -0,0 +1 @@
+select age-10, *, length(name) from people
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_partitioned_table_as_select.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_partitioned_table_as_select.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_partitioned_table_as_select.sql
new file mode 100644
index 0000000..b2d7dce
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_partitioned_table_as_select.sql
@@ -0,0 +1,17 @@
+CREATE TABLE sales (
+ col1 int,
+ col2 int)
+PARTITION BY COLUMN (col3 int, col4 float, col5 text) AS
+
+SELECT
+ col1,
+ col2,
+ col3,
+ col4,
+ col5
+FROM
+ sales_src
+WHERE
+ col1 > 16
+
+
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_1.sql
new file mode 100644
index 0000000..8875b0e
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_1.sql
@@ -0,0 +1 @@
+create table name (name text, age int)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_10.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_10.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_10.sql
new file mode 100644
index 0000000..43314fa
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_10.sql
@@ -0,0 +1 @@
+create external table table1 (name text, age int, earn bigint, score float) using csv location '/tmp/data'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_11.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_11.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_11.sql
new file mode 100644
index 0000000..d6ca3ae
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_11.sql
@@ -0,0 +1,3 @@
+create external table table1 (name text, age int)
+using rcfile
+location '/user/hive/table1'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_12.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_12.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_12.sql
new file mode 100644
index 0000000..99e7b8d
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_12.sql
@@ -0,0 +1,3 @@
+create external table table1 (name text, age int)
+USING text WITH ('text.delimiter'='|')
+location '/user/hive/table1'
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_2.sql
new file mode 100644
index 0000000..4580e82
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_2.sql
@@ -0,0 +1 @@
+create table name (name text, age int) using rcfile
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_3.sql
new file mode 100644
index 0000000..5ab2af2
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_3.sql
@@ -0,0 +1 @@
+create table name (name text, age int) using rcfile with ('rcfile.buffer'=4096)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_4.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_4.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_4.sql
new file mode 100644
index 0000000..fe4d580
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_4.sql
@@ -0,0 +1 @@
+create table name as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_5.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_5.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_5.sql
new file mode 100644
index 0000000..b22b841
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_5.sql
@@ -0,0 +1 @@
+create table name (name text, age int) as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_6.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_6.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_6.sql
new file mode 100644
index 0000000..27e06f2
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_6.sql
@@ -0,0 +1 @@
+create table name (name text, age int) using rcfile as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_7.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_7.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_7.sql
new file mode 100644
index 0000000..5c9bf35
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_7.sql
@@ -0,0 +1 @@
+create table name (name text, age int) using rcfile with ('rcfile.buffer'= 4096) as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_8.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_8.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_8.sql
new file mode 100644
index 0000000..d6c2ae6
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_8.sql
@@ -0,0 +1,48 @@
+create table widetable (
+ col0 bit,
+ col1 BIT(10),
+ col2 bit varying,
+ col3 bit VARYING(10),
+ col4 tinyint,
+ col5 smallInt,
+ col6 integer,
+ col7 biginT,
+ col8 real,
+ col9 float,
+ col10 float(53),
+ col11 double,
+ col12 doublE precision,
+ col13 numeric,
+ col14 numeric(10),
+ col15 numeric(10,2),
+ col16 decimal,
+ col17 decimal(10),
+ col18 decimal(10,2),
+ col19 char,
+ col20 character,
+ col21 chaR(10),
+ col22 character(10),
+ col23 varchar,
+ col24 character varying,
+ col25 varchar(255),
+ col26 character varying (255),
+ col27 nchar,
+ col28 nchar(255),
+ col29 national character,
+ col30 national character(255),
+ col31 nvarchar,
+ col32 nvarchar(255),
+ col33 natIonal character varying,
+ col34 national character varying (255),
+ col35 date,
+ col36 time,
+ col37 timetz,
+ col38 time With time zone,
+ col39 timesTamptz,
+ col40 timestamp with time zone,
+ col41 binary,
+ col42 binary(10),
+ col43 varbinary(10),
+ col44 binary Varying(10),
+ col45 blOb
+) as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_9.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_9.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_9.sql
new file mode 100644
index 0000000..49e1e3c
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_9.sql
@@ -0,0 +1 @@
+create table widetable (col1 float(10), col2 float) as select * from test
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_like_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_like_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_like_1.sql
new file mode 100644
index 0000000..73f2f46
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/create_table_like_1.sql
@@ -0,0 +1 @@
+create table new_table like orig_name;
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/drop_table.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/drop_table.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/drop_table.sql
new file mode 100644
index 0000000..0e52112
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/drop_table.sql
@@ -0,0 +1 @@
+drop table abc
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_1.sql
new file mode 100644
index 0000000..0b10799
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_1.sql
@@ -0,0 +1 @@
+select c1,c2,c3 from table1 where exists (select c4 from table2 where c4 = table1.c1);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_2.sql
new file mode 100644
index 0000000..f4f82f9
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/exists_predicate_2.sql
@@ -0,0 +1 @@
+select c1,c2,c3 from table1 where not exists (select c4 from table2 where c4 = table1.c1);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_1.sql
new file mode 100644
index 0000000..85dbe21
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_1.sql
@@ -0,0 +1 @@
+select col0, col1, col2, col3, sum(col4) as total, avg(col5) from base group by col0, cube (col1, col2), rollup(col3) having total > 100
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_2.sql
new file mode 100644
index 0000000..031cab2
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_2.sql
@@ -0,0 +1 @@
+select col0, col1, col2, col3, sum(col4) as total, avg(col5) from base group by col0, cube (col1, col2), col3 having total > 100
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_3.sql
new file mode 100644
index 0000000..469e8b2
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_3.sql
@@ -0,0 +1 @@
+select col0, col1, col2, col3, sum(col4) as total, avg(col5) from base group by col0, col3, cube (col1, col2) having total > 100
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_4.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_4.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_4.sql
new file mode 100644
index 0000000..749c6d9
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_4.sql
@@ -0,0 +1 @@
+select trim(name), count(1) from table1 group by trim(name)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_5.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_5.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_5.sql
new file mode 100644
index 0000000..f654ef6
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/groupby_5.sql
@@ -0,0 +1 @@
+select id, name, count(*), sum(id), avg(age) from people group by id, name
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_1.sql
new file mode 100644
index 0000000..2a16a8d
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_1.sql
@@ -0,0 +1 @@
+select c1,c2,c3 from table1 where c1 in (select c4 from table2);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_2.sql
new file mode 100644
index 0000000..64c8034
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/in_subquery_2.sql
@@ -0,0 +1 @@
+select c1,c2,c3 from table1 where c1 not in (select c4 from table2);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_1.sql
new file mode 100644
index 0000000..d3291f5
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_1.sql
@@ -0,0 +1 @@
+insert into table1 select col1, col2, sum(col3) from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_2.sql
new file mode 100644
index 0000000..2928b11
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_2.sql
@@ -0,0 +1 @@
+insert into location 'file:/tmp/data' select col1, col2, sum(col3) from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_3.sql
new file mode 100644
index 0000000..b7718dc
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_into_select_3.sql
@@ -0,0 +1 @@
+insert into table1 (col1, col2, col3) select col1, col2, sum(col3) as total from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_1.sql
new file mode 100644
index 0000000..84992bc
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_1.sql
@@ -0,0 +1 @@
+insert overwrite into table1 select col1, col2, sum(col3) from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_2.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_2.sql
new file mode 100644
index 0000000..1c4227b
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_2.sql
@@ -0,0 +1 @@
+insert overwrite into location 'file:/tmp/data' select col1, col2, sum(col3) from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_3.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_3.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_3.sql
new file mode 100644
index 0000000..bfacc01
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/insert_overwrite_into_select_3.sql
@@ -0,0 +1 @@
+insert overwrite into table1 (col1, col2, col3) select col1, col2, sum(col3) as total from table2 group by col1, col2
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_1.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_1.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_1.sql
new file mode 100644
index 0000000..ad27795
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_1.sql
@@ -0,0 +1 @@
+select name, addr from people natural join student natural join professor
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tajo/blob/89c140c0/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_10.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_10.sql b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_10.sql
new file mode 100644
index 0000000..c9056cc
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSQLAnalyzer/positive/join_10.sql
@@ -0,0 +1 @@
+select * from a cross join b, c, d, e
\ No newline at end of file