Examples of AggregateFunction


Examples of org.h2.api.AggregateFunction

            javaClass = Utils.loadUserClass(className);
        }
        Object obj;
        try {
            obj = javaClass.newInstance();
            AggregateFunction agg = (AggregateFunction) obj;
            return agg;
        } catch (Exception e) {
            throw DbException.convert(e);
        }
    }
View Full Code Here

Examples of org.lealone.api.AggregateFunction

            int type = expr.getType();
            argTypes[i] = type;
            argSqlTypes[i] = DataType.convertTypeToSQLType(type);
        }
        try {
            AggregateFunction aggregate = getInstance();
            dataType = DataType.convertSQLTypeToValueType(aggregate.getType(argSqlTypes));
        } catch (SQLException e) {
            throw DbException.convert(e);
        }
        return this;
    }
View Full Code Here

Examples of org.lealone.api.AggregateFunction

            e.setEvaluatable(tableFilter, b);
        }
    }

    private AggregateFunction getInstance() throws SQLException {
        AggregateFunction agg = userAggregate.getInstance();
        agg.init(userConnection);
        return agg;
    }
View Full Code Here

Examples of org.lealone.api.AggregateFunction

        HashMap<Expression, Object> group = select.getCurrentGroup();
        if (group == null) {
            throw DbException.get(ErrorCode.INVALID_USE_OF_AGGREGATE_FUNCTION_1, getSQL());
        }
        try {
            AggregateFunction agg = (AggregateFunction) group.get(this);
            if (agg == null) {
                agg = getInstance();
            }
            Object obj = agg.getResult();
            if (obj == null) {
                return ValueNull.INSTANCE;
            }
            return DataType.convertToValue(session, obj, dataType);
        } catch (SQLException e) {
View Full Code Here

Examples of org.lealone.api.AggregateFunction

            // already visited
            return;
        }
        lastGroupRowId = groupRowId;

        AggregateFunction agg = (AggregateFunction) group.get(this);
        try {
            if (agg == null) {
                agg = getInstance();
                group.put(this, agg);
            }
            Object[] argValues = new Object[args.length];
            Object arg = null;
            for (int i = 0, len = args.length; i < len; i++) {
                Value v = args[i].getValue(session);
                v = v.convertTo(argTypes[i]);
                arg = v.getObject();
                argValues[i] = arg;
            }
            if (args.length == 1) {
                agg.add(arg);
            } else {
                agg.add(argValues);
            }
        } catch (SQLException e) {
            throw DbException.convert(e);
        }
    }
View Full Code Here

Examples of org.lealone.api.AggregateFunction

            javaClass = Utils.loadUserClass(className);
        }
        Object obj;
        try {
            obj = javaClass.newInstance();
            AggregateFunction agg = (AggregateFunction) obj;
            return agg;
        } catch (Exception e) {
            throw DbException.convert(e);
        }
    }
View Full Code Here

Examples of org.ofbiz.sql.AggregateFunction

                    new FieldAll("c", set("partyId"))
                ),
                GenericTestCaseBase.<String, FieldDef>map(
                    "roleTypeId", new FieldDef(new FieldValue("d", "roleTypeId"), null),
                    "roleDescription", new FieldDef(new FieldValue("d", "description"), "roleDescription"),
                    "SUM"new FieldDef(new AggregateFunction("SUM", false, new FieldValue("a", "partyId")), null),
                    "baz"new FieldDef(new FunctionCall("FOO", GenericTestCaseBase.<Value>list(new FieldValue("a", "partyId"), new NumberValue<Integer>(Integer.valueOf(1)))), "baz"),
                    "one"new FieldDef(new MathValue("||", list(new FieldValue("a", "partyId"), new StringValue("-"), new FieldValue("a", "partyTypeId"))), "one"),
                    "cnt1", new FieldDef(new AggregateFunction("COUNT", false, new FieldValue("a", "partyId")), "cnt1"),
                    "cnt2", new FieldDef(new AggregateFunction("COUNT", false, new FieldValue(null, "partyId")), "cnt2"),
                    "cnt3", new FieldDef(new AggregateFunction("COUNT", true, new FieldValue("a", "partyId")), "cnt3")
                ),
                new Table(
                    new TableName("Party", "a"),
                    new Joined(true, new TableName("Person", "b"), list(new KeyMap("partyId", "partyId")),
                        new Joined(true, new TableName("PartyGroup", "c"), list(new KeyMap("partyId", "partyId")),
View Full Code Here

Examples of org.ofbiz.sql.AggregateFunction

        assertEquals(label + ":field-value", fv, v.getValue());
        basicTest(label, AggregateFunction.class, v, name, s, o, matches);
    }

    public void testAggregateFunction() {
        AggregateFunction v1 = new AggregateFunction("COUNT", false, fv2);
        aggregateFunctionTest("v1", v1, "COUNT", false, fv2, "COUNT(a.partyId)", null, false);
        AggregateFunction v2 = new AggregateFunction("COUNT", true, fv2);
        aggregateFunctionTest("v2", v2, "COUNT", true, fv2, "COUNT(DISTINCT a.partyId)", v1, false);
        AggregateFunction v3 = new AggregateFunction("COUNT", true, fv1);
        aggregateFunctionTest("v3", v3, "COUNT", true, fv1, "COUNT(DISTINCT partyId)", v1, false);
        AggregateFunction v4 = new AggregateFunction("COUNT", false, fv1);
        aggregateFunctionTest("v4", v4, "COUNT", false, fv1, "COUNT(partyId)", v1, false);
        AggregateFunction v5 = new AggregateFunction("MAX", false, fv2);
        aggregateFunctionTest("v5", v5, "MAX", false, fv2, "MAX(a.partyId)", v1, false);
        AggregateFunction v6 = new AggregateFunction("COUNT", false, fv2);
        aggregateFunctionTest("v6", v6, "COUNT", false, fv2, "COUNT(a.partyId)", v1, true);
    }
View Full Code Here

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

Examples of org.teiid.language.AggregateFunction

        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
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.