Java Code Examples for org.apache.calcite.sql.type.ReturnTypes#explicit()
The following examples show how to use
org.apache.calcite.sql.type.ReturnTypes#explicit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassRowTypeCache.java From mat-calcite-plugin with Apache License 2.0 | 6 votes |
@Override public RexNode apply(RexBuilderContext context) { RelOptCluster cluster = context.getCluster(); RelDataTypeFactory typeFactory = cluster.getTypeFactory(); final SqlFunction UDF = new SqlUserDefinedFunction( new SqlIdentifier("RESOLVE_SIMPLE", SqlParserPos.ZERO), ReturnTypes.explicit(typeFactory.createJavaType(Object.class)), null, OperandTypes.ANY_ANY, ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false), typeFactory.createJavaType(int.class)), ScalarFunctionImpl.create(IObjectMethods.class, "resolveSimpleValue")); RexBuilder b = context.getBuilder(); RexNode rexNode = b.makeCall(UDF, context.getIObject(), b.makeLiteral(name)); return b.makeCast(dataType, rexNode); }
Example 2
Source File: ClassRowTypeCache.java From mat-calcite-plugin with Apache License 2.0 | 6 votes |
@Override public RexNode apply(RexBuilderContext context) { RelOptCluster cluster = context.getCluster(); RelDataTypeFactory typeFactory = cluster.getTypeFactory(); final SqlFunction UDF = new SqlUserDefinedFunction( new SqlIdentifier("RESOLVE_REFERENCE", SqlParserPos.ZERO), ReturnTypes.explicit(typeFactory.createJavaType(HeapReference.class)), null, OperandTypes.ANY_ANY, ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false), typeFactory.createJavaType(String.class)), ScalarFunctionImpl.create(IObjectMethods.class, "resolveReferenceValue")); RexBuilder b = context.getBuilder(); return b.makeCall(UDF, context.getIObject(), b.makeLiteral(name)); }
Example 3
Source File: ExecutionRexBuilderContext.java From mat-calcite-plugin with Apache License 2.0 | 6 votes |
@Override public RexNode getSnapshot() { if (snapshot == null) { RelDataTypeFactory typeFactory = getCluster().getTypeFactory(); RexBuilder b = getBuilder(); final SqlFunction UDF = new SqlUserDefinedFunction( new SqlIdentifier("GET_SNAPSHOT", SqlParserPos.ZERO), ReturnTypes.explicit(typeFactory.createTypeWithNullability(typeFactory.createJavaType(ISnapshot.class), false)), null, OperandTypes.NUMERIC, ImmutableList.of(typeFactory.createJavaType(Integer.class)), ScalarFunctionImpl.create(SnapshotHolder.class, "get")); snapshot = b.makeCall(UDF, b.makeLiteral(snapshotId, typeFactory.createSqlType(SqlTypeName.INTEGER), false)); } return snapshot; }
Example 4
Source File: RexBuilderContext.java From mat-calcite-plugin with Apache License 2.0 | 6 votes |
public RexNode getIObject() { if (object == null) { RelDataTypeFactory typeFactory = getCluster().getTypeFactory(); RexBuilder b = getBuilder(); final SqlFunction GET_IOBJECT = new SqlUserDefinedFunction( new SqlIdentifier("GET_IOBJECT", SqlParserPos.ZERO), ReturnTypes.explicit(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false)), null, OperandTypes.ANY_ANY, ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(ISnapshot.class), false), typeFactory.createJavaType(int.class)), ScalarFunctionImpl.create(ISnapshotMethods.class, "getIObject")); object = b.makeCall(GET_IOBJECT, getSnapshot(), getIObjectId()); } return object; }
Example 5
Source File: SqlJsonTypeFunction.java From Bats with Apache License 2.0 | 5 votes |
public SqlJsonTypeFunction() { super("JSON_TYPE", SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.VARCHAR, 20), null, OperandTypes.ANY, SqlFunctionCategory.SYSTEM); }
Example 6
Source File: StreamRecordTimestampSqlFunction.java From flink with Apache License 2.0 | 5 votes |
public StreamRecordTimestampSqlFunction() { super( "STREAMRECORD_TIMESTAMP", SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.BIGINT), InferTypes.RETURN_TYPE, OperandTypes.family(SqlTypeFamily.NUMERIC), SqlFunctionCategory.SYSTEM); }
Example 7
Source File: FlinkSqlOperatorTable.java From flink with Apache License 2.0 | 5 votes |
private static SqlReturnTypeInference createTimeIndicatorReturnType(boolean isRowTime) { return ReturnTypes.explicit(factory -> { if (isRowTime) { return ((FlinkTypeFactory) factory).createRowtimeIndicatorType(false); } else { return ((FlinkTypeFactory) factory).createProctimeIndicatorType(false); } }); }
Example 8
Source File: OLAPAggregateRel.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
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); }
Example 9
Source File: HyperLogLog.java From dremio-oss with Apache License 2.0 | 5 votes |
public SqlHllAggFunction() { super("HLL", null, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.VARBINARY, HLL_VARBINARY_SIZE), null, OperandTypes.ANY, SqlFunctionCategory.USER_DEFINED_FUNCTION, false, false ); }
Example 10
Source File: HyperLogLog.java From dremio-oss with Apache License 2.0 | 5 votes |
public SqlHllMergeAggFunction() { super("HLL_MERGE", null, SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.VARBINARY, HLL_VARBINARY_SIZE), null, OperandTypes.BINARY, SqlFunctionCategory.USER_DEFINED_FUNCTION, false, false ); }
Example 11
Source File: OLAPAggregateRel.java From kylin with Apache License 2.0 | 5 votes |
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); }
Example 12
Source File: StreamRecordTimestampSqlFunction.java From flink with Apache License 2.0 | 5 votes |
public StreamRecordTimestampSqlFunction() { super( "STREAMRECORD_TIMESTAMP", SqlKind.OTHER_FUNCTION, ReturnTypes.explicit(SqlTypeName.BIGINT), InferTypes.RETURN_TYPE, OperandTypes.family(SqlTypeFamily.NUMERIC), SqlFunctionCategory.SYSTEM); }
Example 13
Source File: FlinkSqlOperatorTable.java From flink with Apache License 2.0 | 5 votes |
private static SqlReturnTypeInference createTimeIndicatorReturnType(boolean isRowTime) { return ReturnTypes.explicit(factory -> { if (isRowTime) { return ((FlinkTypeFactory) factory).createRowtimeIndicatorType(false); } else { return ((FlinkTypeFactory) factory).createProctimeIndicatorType(false); } }); }
Example 14
Source File: ClassRowTypeCache.java From mat-calcite-plugin with Apache License 2.0 | 5 votes |
public RexNode apply(RexBuilderContext context) { RelOptCluster cluster = context.getCluster(); RelDataTypeFactory typeFactory = cluster.getTypeFactory(); final SqlFunction UDF = new SqlUserDefinedFunction( new SqlIdentifier("TO_REFERENCE", SqlParserPos.ZERO), ReturnTypes.explicit(typeFactory.createJavaType(HeapReference.class)), null, OperandTypes.ANY, ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false)), ScalarFunctionImpl.create(ISnapshotMethods.class, "toReference") ); return context.getBuilder().makeCall(UDF, context.getIObject()); }
Example 15
Source File: SqlDefaultOperator.java From calcite with Apache License 2.0 | 4 votes |
SqlDefaultOperator() { super("DEFAULT", SqlKind.DEFAULT, 100, true, ReturnTypes.explicit(SqlTypeName.ANY), InferTypes.RETURN_TYPE, OperandTypes.NILADIC); }
Example 16
Source File: SqlJsonApiCommonSyntaxOperator.java From Bats with Apache License 2.0 | 4 votes |
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)); }
Example 17
Source File: SqlDefaultOperator.java From Bats with Apache License 2.0 | 4 votes |
SqlDefaultOperator() { super("DEFAULT", SqlKind.DEFAULT, 100, true, ReturnTypes.explicit(SqlTypeName.ANY), InferTypes.RETURN_TYPE, OperandTypes.NILADIC); }