Package org.teiid.query.parser

Examples of org.teiid.query.parser.QueryParser


    }

    public void helpTestVisitor(String sql, String[] expectedGroups) {
        LanguageObject obj = null;
        try {
            QueryParser parser = new QueryParser();
            obj = parser.parseCommand(sql);
        } catch(TeiidException e) {
            fail("Unexpected exception while parsing: " + e.getFullMessage()); //$NON-NLS-1$
        }
       
        Collection actualGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj, false);
View Full Code Here


  }
 
  // ################################## TEST HELPERS ################################ 

  public static final CommandStatement sample1() {
    QueryParser parser = new QueryParser();   
    try {
      Query query = (Query) parser.parseCommand("Select x from y"); //$NON-NLS-1$
      return new CommandStatement(query);
    } catch(Exception e) { return null;}
  }
View Full Code Here

      return new CommandStatement(query);
    } catch(Exception e) { return null;}
  }

  public static final CommandStatement sample2() {
    QueryParser parser = new QueryParser();   
    try {
      Update update = (Update) parser.parseCommand("UPDATE x SET x = 'y'"); //$NON-NLS-1$
      return new CommandStatement(update);
    } catch(Exception e) { return null;}
  }
View Full Code Here

    @Test public void testValidateAssignmentWithFunctionOnParameter_InServer() throws Exception{
        String sql = "EXEC pm1.vsp36(5)"//$NON-NLS-1$
        QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
       
        Command command = new QueryParser().parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);
       
        // Validate
        ValidatorReport report = Validator.validate(command, metadata);
        assertEquals(0, report.getItems().size());                     
View Full Code Here

    }

    @Test public void testDefect9917() throws Exception{
      QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
        String sql = "SELECT lookup('pm1.g1', 'e1a', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
        Command command = new QueryParser().parseCommand(sql);
        try{
          QueryResolver.resolveCommand(command, metadata);
          fail("Did not get exception"); //$NON-NLS-1$
        }catch(QueryResolverException e){
          //expected
        }
       
        sql = "SELECT lookup('pm1.g1a', 'e1', 'e2', e2) AS x, lookup('pm1.g1', 'e4', 'e3', e3) AS y FROM pm1.g1"; //$NON-NLS-1$
        command = new QueryParser().parseCommand(sql);
        try{
          QueryResolver.resolveCommand(command, metadata);
          fail("Did not get exception"); //$NON-NLS-1$
        }catch(QueryResolverException e){
          //expected
View Full Code Here

        ValidatorReport report = Validator.validate(command, metadata);
        assertEquals("The aggregate function SUM cannot be used with non-numeric expressions: SUM(DISTINCT lookup('pm1.g1', 'e3', 'e2', e2))", report.toString()); //$NON-NLS-1$
    }
   
    private ValidatorReport helpValidateInModeler(String procName, String procSql, QueryMetadataInterface metadata) throws Exception {
        Command command = new QueryParser().parseCommand(procSql);
       
        GroupSymbol group = new GroupSymbol(procName);
        QueryResolver.resolveCommand(command, group, Command.TYPE_STORED_PROCEDURE, metadata);
       
        // Validate
View Full Code Here

 
  @Test public void testDefect14886() throws Exception{       
        String sql = "CREATE VIRTUAL PROCEDURE BEGIN END"//$NON-NLS-1$       
        QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
       
        Command command = new QueryParser().parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);
       
        // Validate
        ValidatorReport report = Validator.validate(command, metadata);
        // Validate
View Full Code Here

        String sql = "CREATE VIRTUAL PROCEDURE BEGIN SELECT * INTO #temptable FROM pm1.g1; INSERT INTO #temptable (e1) VALUES ('a'); END"; //$NON-NLS-1$     
        FakeMetadataFacade metadata = FakeMetadataFactory.example1();
        FakeMetadataObject e1 = metadata.getStore().findObject("pm1.g1.e1", FakeMetadataObject.ELEMENT); //$NON-NLS-1$
        e1.putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE);
       
        Command command = new QueryParser().parseCommand(sql);
        QueryResolver.resolveCommand(command, metadata);
       
        // Validate
        ValidatorReport report = Validator.validate(command, metadata);
        // Validate
View Full Code Here

TOP

Related Classes of org.teiid.query.parser.QueryParser

Copyright © 2018 www.massapicom. 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.