Examples of HqlParser


Examples of org.apache.hadoop.hbase.hql.generated.HQLParser

  private ReturnMsg runCommand(final String cmdStr)
  throws ParseException, UnsupportedEncodingException {
    LOG.info("Running command: " + cmdStr);
    Writer out = new OutputStreamWriter(System.out, "UTF-8");
    TableFormatterFactory tff = new TableFormatterFactory(out, this.conf);
    HQLParser parser = new HQLParser(cmdStr, out, tff.get());
    Command cmd = parser.terminatedCommand();
    ReturnMsg rm = cmd.execute(this.conf);
    dumpStdout();
    return rm;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.hql.generated.HQLParser

  if (query.length() > 0) {
      out.write("\n <hr/>\n ");

    HQLParser parser = new HQLParser(query, out, new HtmlTableFormatter(out));
    Command cmd = parser.terminatedCommand();
    if (cmd.getCommandType() != Command.CommandType.SELECT) {
      out.write("\n  <p>");
      out.print( cmd.getCommandType() );
      out.write("-type commands are disabled in this interface.</p>\n ");
View Full Code Here

Examples of org.apache.hadoop.hbase.hql.generated.HQLParser

    tableFormater = formatter;
    MASTER_ADDRESS = master;
  }

  public ReturnMsg executeQuery(String query) {
    HQLParser parser = new HQLParser(query, out, tableFormater);
    ReturnMsg rs = null;

    try {
      Command cmd = parser.terminatedCommand();
      if (cmd != null) {
        rs = cmd.execute(conf);
      }
    } catch (ParseException pe) {
      String[] msg = pe.getMessage().split("[\n]");
View Full Code Here

Examples of org.apache.hadoop.hbase.hql.generated.HQLParser

  public static void main(String[] args) throws Exception {
    Writer out = new OutputStreamWriter(System.out, "UTF-8");
    HBaseConfiguration c = new HBaseConfiguration();
    // For debugging
    TableFormatterFactory tff = new TableFormatterFactory(out, c);
    HQLParser parser = new HQLParser("select * from 'x' where row='x';", out, tff.get());
    Command cmd = parser.terminatedCommand();

    ReturnMsg rm = cmd.execute(c);
    out.write(rm == null ? "" : rm.toString());
    out.flush();
  }
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

  /**
   * Test a simple tree, make sure the iterator encounters every node.
   */
  public void testSimpleTree() throws Exception {
    String input = "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id";
    HqlParser parser = HqlParser.getInstance( input );
    parser.statement();
    AST ast = parser.getAST();
    ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
    printer.showAst( ast, new PrintWriter( System.out ) );
    ASTIterator iterator = new ASTIterator( ast );
    int count = 0;
    while ( iterator.hasNext() ) {
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
    if ( logging ) {
      System.out.println( "input: ->" + input + "<-" );
    }

    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( false );
    parser.statement();
    AST ast = parser.getAST();

    if ( logging ) {
      System.out.println( "AST  :  " + ast.toStringTree() + "" );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst( ast, new PrintStream( baos ) );
      System.out.println( baos.toString() );
    }

    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );

    return ast;
  }
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

  private AST parse(String input, boolean logging) throws RecognitionException, TokenStreamException {
    if ( logging ) {
      System.out.println( "input: ->" + input + "<-" );
    }

    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( false );
    parser.statement();
    AST ast = parser.getAST();

    if ( logging ) {
      System.out.println( "AST  :  " + ast.toStringTree() + "" );
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst( ast, new PrintStream( baos ) );
      System.out.println( baos.toString() );
    }

    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );

    return ast;
  }
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

    parseFilter( "where this.name = ?" );
  }

  public void testNoFrom() throws Exception {
    System.out.println( "***** This test ensures that an error is detected ERROR MESSAGES ARE OKAY!  *****" );
    HqlParser parser = HqlParser.getInstance( "" );
    parser.setFilter( false );
    parser.statement();
    assertEquals( "Parser allowed no FROM clause!", 1, parser.getParseErrorHandler().getErrorCount() );
    System.out.println( "***** END OF ERROR TEST  *****" );
  }
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

    doParse( input, false );
  }

  private AST doParse(String input, boolean filter) throws RecognitionException, TokenStreamException {
    System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars(input) + "<-" );
    HqlParser parser = HqlParser.getInstance( input );
    parser.setFilter( filter );
    parser.statement();
    AST ast = parser.getAST();
    System.out.println( "AST  :  " + ast.toStringTree() + "" );
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    parser.showAst( ast, new PrintStream( baos ) );
    System.out.println( baos.toString() );
    assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );
    return ast;
  }
View Full Code Here

Examples of org.hibernate.hql.ast.HqlParser

  /**
   * Test a simple tree, make sure the iterator encounters every node.
   */
  public void testSimpleTree() throws Exception {
    String input = "select foo from foo in class org.hibernate.test.Foo, fee in class org.hibernate.test.Fee where foo.dependent = fee order by foo.string desc, foo.component.count asc, fee.id";
    HqlParser parser = HqlParser.getInstance( input );
    parser.statement();
    AST ast = parser.getAST();
    ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class );
    printer.showAst( ast, new PrintWriter( System.out ) );
    ASTIterator iterator = new ASTIterator( ast );
    int count = 0;
    while ( iterator.hasNext() ) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.