private boolean isConvertFunctionWithSimpleExpression(Expression expr) { if (expr instanceof Function && ((Function) expr).getName().equals("convert")) { Function f = (Function) expr; Expression param = f.getParameters().get(0); if (param instanceof ColumnReference) { return true; } else if (param instanceof Literal) { return true; } } return false; }
@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) { return Arrays.asList("cast(", function.getParameters().get(0), " as int64)", "%", //$NON-NLS-1$ //$NON-NLS-2$ "cast(",function.getParameters().get(1), " as int64)"); } }); //$NON-NLS-1$
@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 void visit(Function obj) { if (this.executionFactory.getFunctionModifiers().containsKey(obj.getName())) { List<?> parts = this.executionFactory.getFunctionModifiers().get(obj.getName()).translate(obj); if (parts != null) { throw new AssertionError("not supported"); //$NON-NLS-1$ String name = obj.getName(); List<Expression> args = obj.getParameters(); if(isInfixFunction(name)) { this.filter.append(Tokens.LPAREN); FunctionMethod method = obj.getMetadataObject(); if (name.startsWith(method.getCategory())) { name = name.substring(method.getCategory().length()+1);
public void parseFunction( Function func ) { String functionName = func.getName(); try { if (functionName.equalsIgnoreCase("includes")) { //$NON-NLS-1$ generateMultiSelect(func, INCLUDES); } else if (functionName.equalsIgnoreCase("excludes")) { //$NON-NLS-1$ generateMultiSelect(func, EXCLUDES); } } catch (TranslatorException e) { exceptions.add(e); } }
@Override public List<?> translate(Function function) { function.setName("log"); //$NON-NLS-1$ List<Expression> args = function.getParameters(); args.add(args.get(0)); args.set(0, languageFactory.createLiteral(new Integer(10), TypeFacility.RUNTIME_TYPES.INTEGER)); return null; }
public Function createFunction(String functionName, List<? extends Expression> args, Class<?> type) { return new Function(functionName, args, type); }
@Override public List<?> translate(Function function) { function.setName("cast"); //$NON-NLS-1$ int targetCode = getCode(function.getType()); List<Expression> args = function.getParameters(); Class<?> srcType = args.get(0).getType(); int sourceCode = getCode(srcType); ((Literal)function.getParameters().get(1)).setValue(type); return null; return Arrays.asList(function.getParameters().get(0));
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());
public void visit(Function obj) { FunctionMethod f = obj.getMetadataObject(); if (f != null) { String nativeQuery = f.getProperty(TEIID_NATIVE_QUERY, false); if (nativeQuery != null) { List<Argument> args = new ArrayList<Argument>(obj.getParameters().size()); for (Expression p : obj.getParameters()) { args.add(new Argument(Direction.IN, p, p.getType(), null)); } parseNativeQueryParts(nativeQuery, args, buffer, this); return; } } super.visit(obj); }
protected void modify(Function function) { function.setName(alias); }
private BaseColumn setCurrentExpression(Expression leftExpression) { BaseColumn old = currentExpression; if (leftExpression instanceof ColumnReference) { ColumnReference cr = (ColumnReference)leftExpression; currentExpression = cr.getMetadataObject(); } else if (leftExpression instanceof Function) { Function function = (Function)leftExpression; currentExpression = function.getMetadataObject().getOutputParameter(); } else { currentExpression = null; } //we are really looking for the native type, if it's not set then don't bother if (currentExpression != null && currentExpression.getNativeType() == null) { currentExpression = null; } return old; }
@Override public List<?> translate(Function function) { return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$ } });
@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 void visit(Function obj) { if (this.ef.getFunctionModifiers().containsKey(obj.getName())) { List<?> parts = this.ef.getFunctionModifiers().get(obj.getName()).translate(obj); if (parts != null) { throw new AssertionError("not supported"); //$NON-NLS-1$ String name = obj.getName(); List<Expression> args = obj.getParameters(); if(isInfixFunction(name)) { this.filter.append(Tokens.LPAREN); FunctionMethod method = obj.getMetadataObject(); if (name.startsWith(method.getCategory())) { name = name.substring(method.getCategory().length()+1);
@Override public List<?> translate(Function function) { function.setName("log"); //$NON-NLS-1$ List<Expression> args = function.getParameters(); args.add(args.get(0)); args.set(0, languageFactory.createLiteral(new Integer(10), TypeFacility.RUNTIME_TYPES.INTEGER)); return null; }