ApproxCountDistinctSqlAggFunction() { super( NAME, null, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.BIGINT), InferTypes.VARCHAR_1024, OperandTypes.ANY, SqlFunctionCategory.STRING, false, false ); } }
public OperatorBuilder nullableReturnType(final SqlTypeName typeName) { this.returnTypeInference = ReturnTypes.explicit( factory -> Calcites.createSqlTypeWithNullability(factory, typeName, true) ); return this; }
public OperatorBuilder returnType(final SqlTypeName typeName) { this.returnTypeInference = ReturnTypes.explicit( factory -> Calcites.createSqlType(factory, typeName) ); return this; }
private static CalciteUDFInfo getUDFInfo(String hiveUdfName, ImmutableList<RelDataType> calciteArgTypes, RelDataType calciteRetType) { CalciteUDFInfo udfInfo = new CalciteUDFInfo(); udfInfo.udfName = hiveUdfName; udfInfo.returnTypeInference = ReturnTypes.explicit(calciteRetType); udfInfo.operandTypeInference = InferTypes.explicit(calciteArgTypes); ImmutableList.Builder<SqlTypeFamily> typeFamilyBuilder = new ImmutableList.Builder<SqlTypeFamily>(); for (RelDataType at : calciteArgTypes) { typeFamilyBuilder.add(Util.first(at.getSqlTypeName().getFamily(), SqlTypeFamily.ANY)); } udfInfo.operandTypeChecker = OperandTypes.family(typeFamilyBuilder.build()); return udfInfo; }
@Override public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) { RelDataType countRetType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true); return AggregateCall.create( new HiveSqlCountAggFunction(isDistinct, ReturnTypes.explicit(countRetType), operandTypeInference, operandTypeChecker), false, ImmutableIntList.of(), -1, countRetType, "count"); }
@Override public AggregateCall other(RelDataTypeFactory typeFactory, AggregateCall e) { RelDataType countRetType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), true); return AggregateCall.create( new HiveSqlCountAggFunction(isDistinct, ReturnTypes.explicit(countRetType), operandTypeInference, operandTypeChecker), false, ImmutableIntList.of(), -1, countRetType, "count"); }
SqlAggFunction createCustomAggFunction(String funcName, RelDataType returnType, Class<?> customAggFuncClz) { RelDataTypeFactory typeFactory = getCluster().getTypeFactory(); SqlIdentifier sqlIdentifier = new SqlIdentifier(funcName, new SqlParserPos(1, 1)); AggregateFunction aggFunction = AggregateFunctionImpl.create(customAggFuncClz); List<RelDataType> argTypes = new ArrayList<RelDataType>(); List<SqlTypeFamily> typeFamilies = new ArrayList<SqlTypeFamily>(); for (FunctionParameter o : aggFunction.getParameters()) { final RelDataType type = o.getType(typeFactory); argTypes.add(type); typeFamilies.add(Util.first(type.getSqlTypeName().getFamily(), SqlTypeFamily.ANY)); } return new SqlUserDefinedAggFunction(sqlIdentifier, ReturnTypes.explicit(returnType), InferTypes.explicit(argTypes), OperandTypes.family(typeFamilies), aggFunction, false, false, typeFactory); }
QuantileSqlAggFunction() { super( NAME, null, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.DOUBLE), null, OperandTypes.or( OperandTypes.and( OperandTypes.sequence(SIGNATURE1, OperandTypes.ANY, OperandTypes.LITERAL), OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC) ), OperandTypes.and( OperandTypes.sequence(SIGNATURE2, OperandTypes.ANY, OperandTypes.LITERAL, OperandTypes.LITERAL), OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC, SqlTypeFamily.EXACT_NUMERIC) ) ), SqlFunctionCategory.NUMERIC, false, false ); } }
private static CalciteUDFInfo getUDFInfo(String hiveUdfName, ImmutableList<RelDataType> calciteArgTypes, RelDataType calciteRetType) { CalciteUDFInfo udfInfo = new CalciteUDFInfo(); udfInfo.udfName = hiveUdfName; udfInfo.returnTypeInference = ReturnTypes.explicit(calciteRetType); udfInfo.operandTypeInference = InferTypes.explicit(calciteArgTypes); ImmutableList.Builder<SqlTypeFamily> typeFamilyBuilder = new ImmutableList.Builder<SqlTypeFamily>(); for (RelDataType at : calciteArgTypes) { typeFamilyBuilder.add(Util.first(at.getSqlTypeName().getFamily(), SqlTypeFamily.ANY)); } udfInfo.operandTypeChecker = OperandTypes.family(typeFamilyBuilder.build()); return udfInfo; }
new SqlFunction( type.getSqlIdentifier(), ReturnTypes.explicit(type), null, null,
new HiveSqlSumAggFunction( oldCall.isDistinct(), ReturnTypes.explicit(sumSquaredReturnType), InferTypes.explicit(Collections.singletonList(argSquared.getType())), new HiveSqlSumAggFunction( oldCall.isDistinct(), ReturnTypes.explicit(sumReturnType), InferTypes.explicit(Collections.singletonList(argOrdinalType)), new HiveSqlCountAggFunction( oldCall.isDistinct(), ReturnTypes.explicit(countRetType), oldCall.getAggregation().getOperandTypeInference(),
new HiveSqlSumAggFunction( oldCall.isDistinct(), ReturnTypes.explicit(sumReturnType), oldCall.getAggregation().getOperandTypeInference(),
SqlDefaultOperator() { super("DEFAULT", SqlKind.DEFAULT, 100, true, ReturnTypes.explicit(SqlTypeName.ANY), InferTypes.RETURN_TYPE, OperandTypes.NILADIC); }
SqlDefaultOperator() { super("DEFAULT", SqlKind.DEFAULT, 100, true, ReturnTypes.explicit(SqlTypeName.ANY), InferTypes.RETURN_TYPE, OperandTypes.NILADIC); }
/** * Creates an inference rule which returns a copy of a given data type. */ public static ExplicitReturnTypeInference explicit(RelDataType type) { return explicit(RelDataTypeImpl.proto(type)); }
/** * Creates an inference rule which returns a copy of a given data type. */ public static ExplicitReturnTypeInference explicit(RelDataType type) { return explicit(RelDataTypeImpl.proto(type)); }
/** * Creates an inference rule which returns a type with no precision or scale, * such as {@code DATE}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName) { return explicit(RelDataTypeImpl.proto(typeName, false)); }
/** * Creates an inference rule which returns a type with no precision or scale, * such as {@code DATE}. */ public static ExplicitReturnTypeInference explicit(SqlTypeName typeName) { return explicit(RelDataTypeImpl.proto(typeName, false)); }
public SqlJsonApiCommonSyntaxOperator() { super("JSON_API_COMMON_SYNTAX", SqlKind.JSON_API_COMMON_SYNTAX, 100, true, ReturnTypes.explicit(SqlTypeName.ANY), null, OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.STRING)); }