tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [2/3] tajo git commit: TAJO-1467: Parenthesis at the start of SQL query is ignored. (Keuntae Park)
Date Thu, 16 Apr 2015 06:12:03 GMT
TAJO-1467: Parenthesis at the start of SQL query is ignored. (Keuntae Park)

Closes #479


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/338a2b77
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/338a2b77
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/338a2b77

Branch: refs/heads/index_support
Commit: 338a2b777854de0ed8344d3d1fcbc5276f3e3cba
Parents: c42d4b3
Author: Keuntae Park <sirpkt@apache.org>
Authored: Thu Apr 16 13:47:16 2015 +0900
Committer: Keuntae Park <sirpkt@apache.org>
Committed: Thu Apr 16 13:47:16 2015 +0900

----------------------------------------------------------------------
 CHANGES                                               |  3 +++
 .../java/org/apache/tajo/cli/tsql/SimpleParser.java   |  2 +-
 .../org/apache/tajo/engine/parser/SQLAnalyzer.java    | 10 ++++++++++
 .../org/apache/tajo/engine/query/TestSelectQuery.java | 14 ++++++++++++++
 .../TestSelectQuery/testSelectWithParentheses1.sql    |  1 +
 .../TestSelectQuery/testSelectWithParentheses2.sql    |  1 +
 .../TestSelectQuery/testSelectWithParentheses1.result |  3 +++
 .../TestSelectQuery/testSelectWithParentheses2.result |  3 +++
 8 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index bbf99e9..fe8dd8e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -89,6 +89,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1467: Parenthesis at the start of SQL query is ignored. 
+    (Keuntae Park)
+
     TAJO-1541: Connection timeout in netty client is not working.
     (Contributed by navis, Committed by jihun)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/SimpleParser.java
----------------------------------------------------------------------
diff --git a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/SimpleParser.java b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/SimpleParser.java
index b8c4c28..0fc92b0 100644
--- a/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/SimpleParser.java
+++ b/tajo-cli/src/main/java/org/apache/tajo/cli/tsql/SimpleParser.java
@@ -315,7 +315,7 @@ public class SimpleParser {
   }
 
   private boolean isStatementStart(char character) {
-    return state == ParsingState.TOK_START && (Character.isLetterOrDigit(character));
+    return state == ParsingState.TOK_START && (Character.isLetterOrDigit(character)
|| character == '(');
   }
 
   private boolean isStatementContinue() {

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java b/tajo-core/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
index 673b22f..6d32fa5 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/parser/SQLAnalyzer.java
@@ -204,6 +204,16 @@ public class SQLAnalyzer extends SQLParserBaseVisitor<Expr> {
   }
 
   @Override
+  public Expr visitNon_join_query_primary(Non_join_query_primaryContext ctx) {
+    if (ctx.simple_table() != null) {
+      return visitSimple_table(ctx.simple_table());
+    } else if (ctx.non_join_query_expression() != null) {
+      return visitNon_join_query_expression(ctx.non_join_query_expression());
+    }
+    return visitChildren(ctx);
+  }
+
+  @Override
   public Expr visitQuery_specification(SQLParser.Query_specificationContext ctx) {
     Expr current = null;
     if (ctx.table_expression() != null) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
index 176d44e..48a3343 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
@@ -708,4 +708,18 @@ public class TestSelectQuery extends QueryTestCaseBase {
       executeString("DROP TABLE table2");
     }
   }
+
+  @Test
+  public void testSelectWithParentheses1() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
+
+  @Test
+  public void testSelectWithParentheses2() throws Exception {
+    ResultSet res = executeQuery();
+    assertResultSet(res);
+    cleanupQuery(res);
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses1.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses1.sql
b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses1.sql
new file mode 100644
index 0000000..24f5e3b
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses1.sql
@@ -0,0 +1 @@
+(select n_nationkey, n_name from nation where n_nationkey = 1);

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses2.sql
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses2.sql
b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses2.sql
new file mode 100644
index 0000000..1760c99
--- /dev/null
+++ b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectWithParentheses2.sql
@@ -0,0 +1 @@
+(select n1.n_nationkey, n2.n_name from nation n1 join nation n2 on n1.n_nationkey = n2.n_nationkey
where n_nationkey = 1);

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses1.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses1.result
b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses1.result
new file mode 100644
index 0000000..1986676
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses1.result
@@ -0,0 +1,3 @@
+n_nationkey,n_name
+-------------------------------
+1,ARGENTINA

http://git-wip-us.apache.org/repos/asf/tajo/blob/338a2b77/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses2.result
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses2.result
b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses2.result
new file mode 100644
index 0000000..ae3b435
--- /dev/null
+++ b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectWithParentheses2.result
@@ -0,0 +1,3 @@
+n_nationkey,n_name
+-------------------------------
+1,ARGENTINA
\ No newline at end of file


Mime
View raw message