Package org.teiid.language

Examples of org.teiid.language.AggregateFunction


        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)) {
          af.setName("STDDEVP"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.STDDEV_SAMP)) {
          af.setName("STDDEV"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.VAR_POP)) {
          af.setName("VARP"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.VAR_SAMP)) {
          af.setName("VAR"); //$NON-NLS-1$
        }
      }
      return super.translate(obj, context);
    }
View Full Code Here


        assertEquals(expected, getString(TestAggregateImpl.example("COUNT", NonReserved.COUNT, false, 42))); //$NON-NLS-1$
    }

    @Test public void testVisitIAggregateDistinct() throws Exception {
        String expected = "COUNT(DISTINCT *)"; //$NON-NLS-1$
        AggregateFunction impl = new AggregateFunction("COUNT", true, null, Integer.class); //$NON-NLS-1$
        assertEquals(expected, getString(impl));
    }
View Full Code Here

     * @since 4.3
     */
    @Override
    public List<?> translate(LanguageObject obj, ExecutionContext context) {
      if (obj instanceof AggregateFunction) {
        AggregateFunction agg = (AggregateFunction)obj;
        if (agg.getExpression() != null && TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getExpression().getType())) {
              if (agg.getName().equalsIgnoreCase(NonReserved.MIN)) {
                agg.setName("bool_and"); //$NON-NLS-1$
              } else if (agg.getName().equalsIgnoreCase(NonReserved.MAX)) {
                agg.setName("bool_or"); //$NON-NLS-1$
              }
            }
      }
      return super.translate(obj, context);
    }
View Full Code Here

        assertTrue(example("testName", NonReserved.COUNT, true, 42).isDistinct()); //$NON-NLS-1$
        assertFalse(example("testName", NonReserved.COUNT, false, 42).isDistinct()); //$NON-NLS-1$
    }

    public void testGetExpression() throws Exception {
        AggregateFunction agg = example("testName", NonReserved.COUNT, true, 42); //$NON-NLS-1$
        assertNotNull(agg.getExpression());
        assertTrue(agg.getExpression() instanceof Literal);
        assertEquals(new Integer(42), ((Literal)agg.getExpression()).getValue());
    }
View Full Code Here

        }
        return element;
    }

    AggregateFunction translate(AggregateSymbol symbol) {
        return new AggregateFunction(symbol.getAggregateFunction().name(),
                                symbol.isDistinct(),
                                translate(symbol.getExpression()),
                                symbol.getType());
    }
View Full Code Here

    }
   
    @Override
    public List<?> translate(LanguageObject obj, ExecutionContext context) {
      if (obj instanceof AggregateFunction) {
        AggregateFunction af = (AggregateFunction)obj;
        if (af.getName().equals(AggregateFunction.STDDEV_POP)) {
          af.setName("StDevP"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.STDDEV_SAMP)) {
          af.setName("StDev"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.VAR_POP)) {
          af.setName("VarP"); //$NON-NLS-1$
        } else if (af.getName().equals(AggregateFunction.VAR_SAMP)) {
          af.setName("Var"); //$NON-NLS-1$
        }
      }
      return super.translate(obj, context);
    }
View Full Code Here

TOP

Related Classes of org.teiid.language.AggregateFunction

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.