Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-1467

Parenthesis at the start of SQL query is ignored

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.11.0
    • Component/s: None
    • Labels:
      None

      Description

      According to Tajo parser grammar,

      non_join_query_primary
        : simple_table
        | LEFT_PAREN non_join_query_expression RIGHT_PAREN
        ;
      

      it should support following query with parentheses:

      (select n_nationkey, n_name from nation where n_nationkey = 1);
      

      However, isStatementStart() of SimpleParser only accepts digit or letter as a start of SQL query, so that it only takes:

      select n_nationkey, n_name from nation where n_nationkey = 1);
      

      , which results in parser error at SQLParser().

      2015-03-30 11:25:43,765 INFO: org.apache.tajo.master.GlobalEngine (executeQuery(150)) - Query: select n_nationkey, n_name from nation where n_nationkey = 1)
      org.apache.tajo.engine.parser.SQLParseError: ERROR: syntax error at or near '1'
      LINE 1:59 select n_nationkey, n_name from nation where n_nationkey = 1)
                                                                           ^
      	at org.apache.tajo.engine.parser.SQLErrorListener.syntaxError(SQLErrorListener.java:36)
      	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:65)
      	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:473)
      	at org.apache.tajo.engine.parser.SQLErrorStrategy.reportNoViableAltException(SQLErrorStrategy.java:57)
      	at org.apache.tajo.engine.parser.SQLErrorStrategy.reportError(SQLErrorStrategy.java:35)
      	at org.apache.tajo.engine.parser.SQLParser.row_value_predicand(SQLParser.java:9676)
      	at org.apache.tajo.engine.parser.SQLParser.comparison_predicate(SQLParser.java:14355)
      	at org.apache.tajo.engine.parser.SQLParser.predicate(SQLParser.java:14264)
      	at org.apache.tajo.engine.parser.SQLParser.boolean_primary(SQLParser.java:9202)
      	at org.apache.tajo.engine.parser.SQLParser.boolean_test(SQLParser.java:9040)
      	at org.apache.tajo.engine.parser.SQLParser.boolean_factor(SQLParser.java:8983)
      	at org.apache.tajo.engine.parser.SQLParser.and_predicate(SQLParser.java:8920)
      	at org.apache.tajo.engine.parser.SQLParser.or_predicate(SQLParser.java:8850)
      	at org.apache.tajo.engine.parser.SQLParser.boolean_value_expression(SQLParser.java:8796)
      	at org.apache.tajo.engine.parser.SQLParser.value_expression(SQLParser.java:6960)
      	at org.apache.tajo.engine.parser.SQLParser.search_condition(SQLParser.java:11175)
      	at org.apache.tajo.engine.parser.SQLParser.where_clause(SQLParser.java:11132)
      	at org.apache.tajo.engine.parser.SQLParser.table_expression(SQLParser.java:9796)
      	at org.apache.tajo.engine.parser.SQLParser.query_specification(SQLParser.java:13551)
      	at org.apache.tajo.engine.parser.SQLParser.simple_table(SQLParser.java:13261)
      	at org.apache.tajo.engine.parser.SQLParser.non_join_query_primary(SQLParser.java:13200)
      	at org.apache.tajo.engine.parser.SQLParser.non_join_query_term(SQLParser.java:13039)
      	at org.apache.tajo.engine.parser.SQLParser.non_join_query_expression(SQLParser.java:12851)
      	at org.apache.tajo.engine.parser.SQLParser.query_expression_body(SQLParser.java:12769)
      	at org.apache.tajo.engine.parser.SQLParser.query_expression(SQLParser.java:12720)
      	at org.apache.tajo.engine.parser.SQLParser.data_statement(SQLParser.java:679)
      	at org.apache.tajo.engine.parser.SQLParser.statement(SQLParser.java:432)
      	at org.apache.tajo.engine.parser.SQLParser.sql(SQLParser.java:307)
      	at org.apache.tajo.engine.parser.SQLAnalyzer.parse(SQLAnalyzer.java:65)
      	at org.apache.tajo.master.GlobalEngine.buildExpressionFromSql(GlobalEngine.java:190)
      	at org.apache.tajo.master.GlobalEngine.executeQuery(GlobalEngine.java:158)
      	at org.apache.tajo.master.TajoMasterClientService$TajoMasterClientProtocolServiceHandler.submitQuery(TajoMasterClientService.java:287)
      	at org.apache.tajo.ipc.TajoMasterClientProtocol$TajoMasterClientProtocolService$2.callBlockingMethod(TajoMasterClientProtocol.java:543)
      	at org.apache.tajo.rpc.BlockingRpcServer$ServerHandler.channelRead(BlockingRpcServer.java:113)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
      	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
      	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:182)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
      	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
      	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
      	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
      	at java.lang.Thread.run(Thread.java:695)
      

      As most DBMSs support above type of queries with parentheses and Tajo grammar does also,
      I think SimpleParser should be changed to accept parenthesis as a start character of a query.

        Attachments

          Activity

            People

            • Assignee:
              sirpkt Keuntae Park
              Reporter:
              sirpkt Keuntae Park
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: