public Function createFunction(String functionName, List<? extends Expression> args, Class<?> type) { return new Function(functionName, args, type); }
@Override public Expression translateGeometrySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASEWKB, Arrays.asList(expr), TypeFacility.RUNTIME_TYPES.VARBINARY); }
/** * Translate GEOMETRY column reference into an expression that * will return WKB and possibly the SRID. * * @param expr * @return */ public Expression translateGeometrySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASBINARY, Arrays.asList(expr), TypeFacility.RUNTIME_TYPES.BLOB); }
@Override public Expression translateGeometrySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASGML, Arrays.asList(expr), TypeFacility.RUNTIME_TYPES.CLOB); }
public Function createFunction(String functionName, Expression[] args, Class<?> type) { return new Function(functionName, Arrays.asList(args), type); }
@Override public Expression translateGeometrySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASEWKB, Arrays.asList(expr), TypeFacility.RUNTIME_TYPES.BLOB); }
private Function toNChar(Expression ex) { return new Function(TO_NCHAR, Arrays.asList(ex), TypeFacility.RUNTIME_TYPES.STRING); }
@Override public Expression translateGeographySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASEWKB, Arrays.asList( new Function("CAST", //$NON-NLS-1$ Arrays.asList(expr, new Literal("geometry", TypeFacility.RUNTIME_TYPES.STRING)), //$NON-NLS-1$ TypeFacility.RUNTIME_TYPES.GEOMETRY)), TypeFacility.RUNTIME_TYPES.VARBINARY); }
@Override public Expression translateGeographySelect(Expression expr) { return new Function(SourceSystemFunctions.ST_ASEWKB, Arrays.asList( new Function("CAST", //$NON-NLS-1$ Arrays.asList(expr, new Literal("geometry", TypeFacility.RUNTIME_TYPES.STRING)), //$NON-NLS-1$ TypeFacility.RUNTIME_TYPES.GEOMETRY)), TypeFacility.RUNTIME_TYPES.BLOB); }
@Override public List<?> translate(Function function) { Expression ex = function.getParameters().get(0); if (ex instanceof Parameter || ex instanceof Literal) { function.getParameters().set(0, new Function("TO_BLOB", Arrays.asList(ex), TypeFacility.RUNTIME_TYPES.BLOB)); //$NON-NLS-1$ } return super.translate(function); } });
@Override public List<?> translate(Function function) { Expression ex = function.getParameters().get(0); if (ex instanceof Parameter || ex instanceof Literal) { function.getParameters().set(0, new Function("TO_CLOB", Arrays.asList(ex), TypeFacility.RUNTIME_TYPES.CLOB)); //$NON-NLS-1$ } return super.translate(function); } });
@Override public List<?> translate(Function function) { if (function.getParameters().size() != 3) { return null; } Expression param2 = function.getParameters().get(1); param2 = new Function(SourceSystemFunctions.ADD_OP, Arrays.asList(param2, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)), TypeFacility.RUNTIME_TYPES.INTEGER); function.getParameters().set(1, param2); return null; } });
@Override public List<?> translate(Function function) { if (function.getParameters().size() != 3) { return null; } Expression param2 = function.getParameters().get(1); param2 = new Function(SourceSystemFunctions.ADD_OP, Arrays.asList(param2, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)), TypeFacility.RUNTIME_TYPES.INTEGER); function.getParameters().set(1, param2); return null; } });
@Override public List<?> translate(Function function) { function.setName(SourceSystemFunctions.ADD_OP); Expression param1 = function.getParameters().get(0); Expression param2 = function.getParameters().get(1); Function indexOf = new Function("indexof", Arrays.asList(param2, param1), TypeFacility.RUNTIME_TYPES.INTEGER); //$NON-NLS-1$ indexOf.setMetadataObject(function.getMetadataObject()); function.getParameters().set(0, indexOf); function.getParameters().set(1, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)); return null; } });
@Override public List<?> translate(Function function) { function.setName(SourceSystemFunctions.ADD_OP); Expression param1 = function.getParameters().get(0); Expression param2 = function.getParameters().get(1); Function indexOf = new Function("indexof", Arrays.asList(param2, param1), TypeFacility.RUNTIME_TYPES.INTEGER); //$NON-NLS-1$ indexOf.setMetadataObject(function.getMetadataObject()); function.getParameters().set(0, indexOf); function.getParameters().set(1, new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)); return null; } });
@Override public List<?> translate(Function function) { if (function.getParameters().size() > 1) { Expression ex = function.getParameters().get(0); if (ex.getType() == TypeFacility.RUNTIME_TYPES.DOUBLE || ex.getType() == TypeFacility.RUNTIME_TYPES.FLOAT) { if (function.getParameters().get(1) instanceof Literal && Integer.valueOf(0).equals(((Literal)function.getParameters().get(1)).getValue())) { function.getParameters().remove(1); } else { function.getParameters().set(0, new Function(SourceSystemFunctions.CONVERT, Arrays.asList(ex, new Literal("bigdecimal", TypeFacility.RUNTIME_TYPES.STRING)), TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)); //$NON-NLS-1$ } } } return null; } });
isNegative = value < 0; Function length = new Function( SourceSystemFunctions.LENGTH, Arrays.asList(function.getParameters().get(0)), SearchedCase adjustedFrom = new SearchedCase(Arrays.asList(new SearchedWhenClause(new Comparison(from, length, Operator.GT), new Function( SourceSystemFunctions.ADD_OP, Arrays.asList( function.getParameters().set(1, adjustedFrom); Expression maxLength = new Function( SourceSystemFunctions.SUBTRACT_OP, Arrays.asList(length, new Function( SourceSystemFunctions.SUBTRACT_OP, Arrays.asList(
params.set(1, new org.teiid.language.Function(SourceSystemFunctions.CONVERT, Arrays.asList(params.get(1), new Literal(DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataClasses.STRING)), DataTypeManager.DefaultDataClasses.INTEGER)); org.teiid.language.Function result = new org.teiid.language.Function(name, params, function.getType()); if (function.getFunctionDescriptor() != null) { result.setMetadataObject(function.getFunctionDescriptor().getMethod());
params.set(1, new org.teiid.language.Function(SourceSystemFunctions.CONVERT, Arrays.asList(params.get(1), new Literal(DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataClasses.STRING)), DataTypeManager.DefaultDataClasses.INTEGER)); org.teiid.language.Function result = new org.teiid.language.Function(name, params, function.getType()); if (function.getFunctionDescriptor() != null) { result.setMetadataObject(function.getFunctionDescriptor().getMethod());
org.teiid.language.Function result = new org.teiid.language.Function(name, params, function.getType()); if (function.getFunctionDescriptor() != null) { result.setMetadataObject(function.getFunctionDescriptor().getMethod());