Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Select


     * we do this mark the nodes selected and their parents as selected, then we sweep to mark
     * everybody who is not marked "included" as excluded.
     * @param xmlCommand
     */
    static MappingDocument preMarkExcluded(Query xmlCommand, MappingDocument doc) {
        Select select = xmlCommand.getSelect();
        SelectSymbol firstSymbol = select.getSymbol(0);

        // 0. mark the nodes to be excluded
        if(firstSymbol instanceof AllSymbol) {
            return doc;
        }
View Full Code Here


    }
   
    public Query createBaseQuery() {
        Query query = new Query();
       
        Select select = new Select();
        select.addSymbol(getElementSymbol(1,1));
        query.setSelect(select);
       
        From from = new From();
        from.addGroup(getPhysicalGroup(1));
        query.setFrom(from);
View Full Code Here

  void resolveXMLSelect(Query query, GroupSymbol group, List<ElementSymbol> validElements, QueryMetadataInterface metadata)
    throws QueryMetadataException, TeiidComponentException, QueryResolverException {
       
        GroupContext externalGroups = null;

    Select select = query.getSelect();
    // Allow SELECT DISTINCT, which is ignored.  It is meaningless except for
    // self-entity relation using relate() functionality

    List elements = select.getSymbols();
    for (int i = 0; i < elements.size(); i++) {
      SelectSymbol ss = (SelectSymbol) elements.get(i);

      if (ss instanceof ElementSymbol) {
        // Here we make an assumption that: all elements named with "xml" must use qualified name
        // rather than a simple "xml" in order to distinguish it from "SELECT xml" and
        // "SELECT model.document.xml" case, both of whom stand for selecting the whole document.

        // Then "SELECT xml" or "SELECT model.document.xml" can only stand for one meaning with two cases:
        // 1) whole document
        // 2) whole document, root name = "xml", too

        // There are other cases of "xml", such as, element name = "xml",
        // but those are ok because those will be resolved later as normal elements
        String symbolName = ss.getName();
        if(symbolName.equalsIgnoreCase("xml") || symbolName.equalsIgnoreCase(group.getName() + ".xml")) { //$NON-NLS-1$ //$NON-NLS-2$
          if(elements.size() != 1) {
            throw new QueryResolverException(QueryPlugin.Util.getString("XMLQueryResolver.xml_only_valid_alone")); //$NON-NLS-1$
          }
          select.clearSymbols();
                    AllSymbol all = new AllSymbol();
                    all.setElementSymbols(validElements);
          select.addSymbol(all);
          query.setSelect(select);
          return;
        }
                // normal elements
        resolveElement((ElementSymbol)ss, validElements, externalGroups, metadata);
      } else if (ss instanceof AllInGroupSymbol) {
        // Resolve the element with "*" case. such as "A.*"
        // by stripping off the ".*" part,
        String symbolName = ss.getName();
        int index = symbolName.indexOf("*"); //$NON-NLS-1$
        String elementPart = symbolName.substring(0, index-1);

                // Check for case where we have model.doc.*
                if(elementPart.equalsIgnoreCase(group.getName())) {
                    select.clearSymbols();
                    AllSymbol all = new AllSymbol();
                    all.setElementSymbols(validElements);
                    select.addSymbol(all);
                    query.setSelect(select);
                } else {
                    // resovlve the node which is specified
                    ElementSymbol elementSymbol = new ElementSymbol(elementPart);
                    resolveElement(elementSymbol, validElements, externalGroups, metadata);
View Full Code Here

    }
   
    @Test public void testArrayTable() throws Exception {
      String sql = "SELECT * from arraytable(null columns x string, y date) as x"; //$NON-NLS-1$
        Query query = new Query();
        query.setSelect(new Select(Arrays.asList(new AllSymbol())));
        ArrayTable tt = new ArrayTable();
        tt.setArrayValue(new Constant(null, DataTypeManager.DefaultDataClasses.OBJECT));
        List<TableFunctionReference.ProjectedColumn> columns = new ArrayList<TableFunctionReference.ProjectedColumn>();
        columns.add(new TableFunctionReference.ProjectedColumn("x", "string"));
        columns.add(new TableFunctionReference.ProjectedColumn("y", "date"));
View Full Code Here

    }
   
    @Test public void testPositionalReference() throws Exception {
      String sql = "select $1";
      Query query = new Query();
      query.setSelect(new Select(Arrays.asList(new ExpressionSymbol("foo", new Reference(0)))));
        helpTest(sql, "SELECT ?", query);
    }
View Full Code Here

  @Test public void testStringNotEqualDoubleTicks(){
    GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
    From from = new From();
    from.addGroup(g);

    Select select = new Select();
    ElementSymbol a = new ElementSymbol("a")//$NON-NLS-1$
    select.addSymbol(a);

    Expression ex = new ElementSymbol("value"); //$NON-NLS-1$
    Criteria crit = new CompareCriteria(a, CompareCriteria.NE, ex);

    Query query = new Query();
View Full Code Here

    @Test public void testNotEquals2(){
        GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
        From from = new From();
        from.addGroup(g);

        Select select = new Select();
        ElementSymbol a = new ElementSymbol("a")//$NON-NLS-1$
        select.addSymbol(a);

        Expression constant = new Constant("value"); //$NON-NLS-1$
        Criteria crit = new CompareCriteria(a, CompareCriteria.NE, constant);

        Query query = new Query();
View Full Code Here

  @Test public void testPartlyQuotedGroup(){
    GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
    From from = new From();
    from.addGroup(g);

    Select select = new Select();
    ElementSymbol a = new ElementSymbol("a")//$NON-NLS-1$
    select.addSymbol(a);
   
    Criteria crit = new CompareCriteria(a, CompareCriteria.EQ, new Constant(new Integer(5)));

    Query query = new Query();
    query.setSelect(select);
View Full Code Here

  @Test public void testFullyQuotedGroup(){
    GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
    From from = new From();
    from.addGroup(g);

    Select select = new Select();
    ElementSymbol a = new ElementSymbol("a")//$NON-NLS-1$
    select.addSymbol(a);
   
    Criteria crit = new CompareCriteria(a, CompareCriteria.EQ, new Constant(new Integer(5)));

    Query query = new Query();
    query.setSelect(select);
View Full Code Here

  @Test public void testPartlyQuotedElement1(){
    GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
    From from = new From();
    from.addGroup(g);

    Select select = new Select();
    ElementSymbol a = new ElementSymbol("db.g.a")//$NON-NLS-1$
    select.addSymbol(a);

    Query query = new Query();
    query.setSelect(select);
    query.setFrom(from);
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Select

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.