@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(pi()).div(inline(180)); default: return function("radians", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(inline(180)).div(pi()); default: return DSL.field("{degrees}({0})", SQLDataType.NUMERIC, argument); } } }
/** * Get the hyperbolic cotangent function: coth(field). * <p> * This is not supported by any RDBMS, but emulated using exp exp: * <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2) - 1)</pre></code> */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) public static Field<BigDecimal> coth(Field<? extends Number> field) { field = nullSafe(field); return exp(field.mul(2)).add(1).div(exp(field.mul(2)).sub(1)); }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxxxxx xxxx xxxxxxx xx [/pro] */ case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(pi()).div(inline(180)); default: return function("radians", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxx xxxxxxx xxxx xxxxxxx xx [/pro] */ case FIREBIRD: case SQLITE: return argument.cast(BigDecimal.class).mul(inline(180)).div(pi()); default: return field("{degrees}({0})", SQLDataType.NUMERIC, argument); } } }
/** * Get the hyperbolic cotangent function: coth(field). * <p> * This is not supported by any RDBMS, but simulated using exp exp: * <code><pre>(exp([field] * 2) + 1) / (exp([field] * 2) - 1)</pre></code> */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES }) @Transition( name = "COTH", args = "Field", to = "MathFunction" ) public static Field<BigDecimal> coth(Field<? extends Number> field) { field = nullSafe(field); return exp(field.mul(2)).add(1).div(exp(field.mul(2)).sub(1)); }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).add(one()).div(DSL.exp(argument).mul(two())); default: return function("cosh", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).sub(one()).div(DSL.exp(argument).mul(two())); default: return function("sinh", SQLDataType.NUMERIC, argument); } } }
private static final FieldOrRow parseFactor(ParserContext ctx, Type type) { FieldOrRow r = parseExp(ctx, type); if (N.is(type) && r instanceof Field) for (;;) if (!peek(ctx, "*=") && parseIf(ctx, '*')) r = ((Field) r).mul((Field) parseExp(ctx, type)); else if (parseIf(ctx, '/')) r = ((Field) r).div((Field) parseExp(ctx, type)); else if (parseIf(ctx, '%')) r = ((Field) r).mod((Field) parseExp(ctx, type)); else break; return r; }
case H2: case HSQLDB: return DSL.ln(argument).div(DSL.ln(inline(base)));
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.family()) { case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).sub(one()).div(DSL.exp(argument.mul(two())).add(one())); default: return function("tanh", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxx xxxx xxxxxxxxxx xxxx xxxxxxx xx [/pro] */ case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).sub(one()).div(DSL.exp(argument).mul(two())); default: return function("sinh", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxx xxxx xxxxxxxxxx xxxx xxxxxxx xx [/pro] */ case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).add(one()).div(DSL.exp(argument).mul(two())); default: return function("cosh", SQLDataType.NUMERIC, argument); } } }
@Override final Field<BigDecimal> getFunction0(Configuration configuration) { switch (configuration.dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxx xxxx xxxx xxxxxxx xxxx xxxxxxxxxx xxxx xxxxxxx xx [/pro] */ case CUBRID: case HSQLDB: case MARIADB: case MYSQL: case POSTGRES: return DSL.exp(argument.mul(two())).sub(one()).div(DSL.exp(argument.mul(two())).add(one())); default: return function("tanh", SQLDataType.NUMERIC, argument); } } }
case H2: case HSQLDB: return DSL.ln(argument).div(DSL.ln(inline(base)));
@SuppressWarnings({ "unchecked" }) @Override public void accept(Context<?> ctx) { switch (ctx.family()) { case POSTGRES: ctx.visit(DSL.field("{width_bucket}({0}, {1}, {2}, {3})", getType(), field, low, high, buckets)); break; default: ctx.visit( DSL.when(field.lt(low), zero()) .when(field.ge(high), buckets.add(one())) .otherwise((Field<Integer>) DSL.floor(field.sub(low).mul(buckets).div(high.sub(low))).add(one())) ); break; } }
return lhs.div((Field<? extends Number>) DSL.power(two(), rhsAsNumber()).cast(lhs));