Search in sources :

Example 1 with SqlOperatorBinding

use of org.apache.calcite.sql.SqlOperatorBinding in project calcite by apache.

the class CalciteCatalogReader method infer.

private static SqlReturnTypeInference infer(final ScalarFunction function) {
    return new SqlReturnTypeInference() {

        public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
            final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
            final RelDataType type;
            if (function instanceof ScalarFunctionImpl) {
                type = ((ScalarFunctionImpl) function).getReturnType(typeFactory, opBinding);
            } else {
                type = function.getReturnType(typeFactory);
            }
            return toSql(typeFactory, type);
        }
    };
}
Also used : SqlOperatorBinding(org.apache.calcite.sql.SqlOperatorBinding) ScalarFunctionImpl(org.apache.calcite.schema.impl.ScalarFunctionImpl) SqlReturnTypeInference(org.apache.calcite.sql.type.SqlReturnTypeInference) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) RelDataType(org.apache.calcite.rel.type.RelDataType)

Example 2 with SqlOperatorBinding

use of org.apache.calcite.sql.SqlOperatorBinding in project calcite by apache.

the class CalciteCatalogReader method infer.

private static SqlReturnTypeInference infer(final AggregateFunction function) {
    return new SqlReturnTypeInference() {

        public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
            final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
            final RelDataType type = function.getReturnType(typeFactory);
            return toSql(typeFactory, type);
        }
    };
}
Also used : SqlOperatorBinding(org.apache.calcite.sql.SqlOperatorBinding) SqlReturnTypeInference(org.apache.calcite.sql.type.SqlReturnTypeInference) RelDataTypeFactory(org.apache.calcite.rel.type.RelDataTypeFactory) RelDataType(org.apache.calcite.rel.type.RelDataType)

Aggregations

RelDataType (org.apache.calcite.rel.type.RelDataType)2 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)2 SqlOperatorBinding (org.apache.calcite.sql.SqlOperatorBinding)2 SqlReturnTypeInference (org.apache.calcite.sql.type.SqlReturnTypeInference)2 ScalarFunctionImpl (org.apache.calcite.schema.impl.ScalarFunctionImpl)1