Package org.teiid.language

Examples of org.teiid.language.ColumnReference


        helpTestMod(arg1, "EXTRACT(DAY FROM {ts '2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
    }   

    public void test11() throws Exception {
        NamedTable group = LANG_FACTORY.createNamedTable("group", null, null); //$NON-NLS-1$
        ColumnReference elem = LANG_FACTORY.createColumnReference("col", group, null, TypeFacility.RUNTIME_TYPES.DATE); //$NON-NLS-1$
        helpTestMod(elem, "EXTRACT(DAY FROM group.col)", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here


        helpTestMod(elem, "EXTRACT(DAY FROM group.col)", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
    public void test12() throws Exception {
        NamedTable group = LANG_FACTORY.createNamedTable("group", null, null); //$NON-NLS-1$
        ColumnReference elem = LANG_FACTORY.createColumnReference("col", group, null, TypeFacility.RUNTIME_TYPES.DATE); //$NON-NLS-1$
        helpTestMod(elem, "(EXTRACT(DOW FROM group.col) + 1)", SourceSystemFunctions.DAYOFWEEK); //$NON-NLS-1$
    }
View Full Code Here

      {
        Expression expr = iter.next();
        if (expr instanceof ColumnReference) {
          boolean dotAll = false;
          boolean useSelector = false;
          ColumnReference cr = (ColumnReference)expr;
          Column c = cr.getMetadataObject();
          if (c != null) {
            if ("\"mode:properties\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
              dotAll = true;
              useSelector = true;
            } else if ("\"jcr:path\"".equalsIgnoreCase(c.getNameInSource())) { //$NON-NLS-1$
View Full Code Here

    }
    public LanguageObject example1() {
        NamedTable g = new NamedTable("g1", null, null); //$NON-NLS-1$
        List symbols = new ArrayList();       
        symbols.add(new ColumnReference(g, "e1", null, String.class)); //$NON-NLS-1$
        Function function = new Function("length", Arrays.asList(new ColumnReference(g, "e2", null, String.class)), Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
        symbols.add(function);
        List groups = new ArrayList();
        groups.add(g);
        Select q = new Select(symbols, false, groups, null, null, null, null);
            
View Full Code Here

        assertEquals("Did not get expected groups", expectedGroups, actualGroups);         //$NON-NLS-1$
    }
   
    public void test1() {
        NamedTable g1 = new NamedTable("g1", null, null); //$NON-NLS-1$
        ColumnReference e1 = new ColumnReference(g1, "e1", null, String.class); //$NON-NLS-1$
       
        helpTestElementsUsedByGroups(e1, new String[] {"g1.e1"}, new String[] {"g1"}); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

        helpTestElementsUsedByGroups(e1, new String[] {"g1.e1"}, new String[] {"g1"}); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
    public void test2() {
        NamedTable g1 = new NamedTable("g1", null, null); //$NON-NLS-1$
        ColumnReference e1 = new ColumnReference(g1, "e1", null, String.class); //$NON-NLS-1$
        ColumnReference e2 = new ColumnReference(g1, "e2", null, String.class); //$NON-NLS-1$
        Comparison cc = new Comparison(e1, e2, Operator.EQ);
       
        helpTestElementsUsedByGroups(cc, new String[] {"g1.e1", "g1.e2"}, new String[] {"g1"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
View Full Code Here

  }
 
    @Override
    public List<?> translate(LanguageObject obj, ExecutionContext context) {
      if (obj instanceof ColumnReference) {
        ColumnReference elem = (ColumnReference)obj;
      if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && elem.getMetadataObject() != null && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
        return Arrays.asList("cast(", elem, " as char(36))"); //$NON-NLS-1$ //$NON-NLS-2$
      }
      } else if (obj instanceof AggregateFunction) {
        AggregateFunction af = (AggregateFunction)obj;
        if (af.getName().equals(AggregateFunction.STDDEV_POP)) {
View Full Code Here

    }
   
    @Test public void testVisitConvertFunctionOracleStyle() throws Exception {
        String expected = "convert(columnA, integer)"; //$NON-NLS-1$
       
        List<? extends Expression> params = Arrays.asList(new ColumnReference(null, "columnA", null, String.class), new Literal("integer", String.class));
        Function test = new Function("convert", params, Integer.class); //$NON-NLS-1$
       
        assertEquals(expected, getString(test));
    }
View Full Code Here

    }
    else if (tgtType.equals(String.class) && (expr instanceof Function)) {
     
      Function func = (Function)expr;
      if (func.getParameters().get(0) instanceof ColumnReference) {
        ColumnReference ref = (ColumnReference)func.getParameters().get(0);
        if(Number.class.isAssignableFrom(ref.getType())) {
          ArrayList target = new ArrayList();
          target.add("cast("); //$NON-NLS-1$
          target.add(func.getParameters().get(0));
          target.add(" AS varchar(100))"); //$NON-NLS-1$
        }
View Full Code Here

      } else if (obj instanceof Command) {
        parts = translateCommand((Command)obj, context);
      } else if (obj instanceof Limit) {
        parts = translateLimit((Limit)obj, context);
      } else if (obj instanceof ColumnReference) {
        ColumnReference elem = (ColumnReference)obj;
      if (isTrimStrings() && elem.getType() == TypeFacility.RUNTIME_TYPES.STRING && elem.getMetadataObject() != null
          && ("char".equalsIgnoreCase(elem.getMetadataObject().getNativeType()) || "nchar".equalsIgnoreCase(elem.getMetadataObject().getNativeType()))) { //$NON-NLS-1$ //$NON-NLS-2$
        return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.RTRIM, new Expression[] {elem}, TypeFacility.RUNTIME_TYPES.STRING));
      }
      }
      return parts;
    }
View Full Code Here

TOP

Related Classes of org.teiid.language.ColumnReference

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.