@Override public Boolean matchesPkColumn(int pkIndex, Expression ex) { if (ex instanceof Function) { Function f = (Function)ex; ex = f.getArg(0); } return (pkColumns[pkIndex].equals(ex)); }
@Override public Boolean matchesPkColumn(int pkIndex, Expression ex) { if (ex instanceof Function) { Function f = (Function)ex; ex = f.getArg(0); } return (pkColumns[pkIndex].equals(ex)); }
@Override public Boolean matchesPkColumn(int pkIndex, Expression ex) { if (ex instanceof Function) { Function f = (Function)ex; ex = f.getArg(0); } return (pkColumns[pkIndex].equals(ex)); }
Class<?> fromType = function.getArg(0).getType(); Class<?> targetType = function.getType(); if (fromType == targetType) {
/** * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression) */ public Expression replaceExpression(Expression exp) { if (exp instanceof Function){ Function function = (Function)exp; if (function.getName().equalsIgnoreCase(FunctionLibrary.CONTEXT)){ this.contextFunctions.add(function); //return 2nd argument to 'context' return function.getArg(1); } } return exp; }
public void testExecParamNestedFunction() { StoredProcedure exec = new StoredProcedure(); exec.setProcedureName("pm1.proc1"); //$NON-NLS-1$ exec.setProcedureID("proc"); //$NON-NLS-1$ Function f = new Function("length", new Expression[] { exampleElement(true, 1) }); //$NON-NLS-1$ Function f2 = new Function("+", new Expression[] { f, new Constant(new Integer(1)) }); //$NON-NLS-1$ SPParameter param1 = new SPParameter(1, f2); exec.setParameter(param1); // Run symbol mapper StaticSymbolMappingVisitor visitor = new StaticSymbolMappingVisitor(getSymbolMap()); DeepPreOrderNavigator.doVisit(exec, visitor); // Check that element got switched Function afterFunc = (Function) param1.getExpression(); Function innerFunc = (Function) afterFunc.getArgs()[0]; assertEquals("Stored proc param did not get mapped correctly: ", exampleElement(false, 1), innerFunc.getArg(0)); //$NON-NLS-1$ }
private boolean isConstantConvert(Expression ex) { if (ex instanceof Constant) { return true; } if (!(ex instanceof Function)) { return false; } Function f = (Function)ex; if (!FunctionLibrary.isConvert(f)) { return false; } return isConstantConvert(f.getArg(0)); }
private boolean isConstantConvert(Expression ex) { if (ex instanceof Constant) { return true; } if (!(ex instanceof Function)) { return false; } Function f = (Function)ex; if (!FunctionLibrary.isConvert(f)) { return false; } return isConstantConvert(f.getArg(0)); }
private boolean isConstantConvert(Expression ex) { if (ex instanceof Constant) { return true; } if (!(ex instanceof Function)) { return false; } Function f = (Function)ex; if (!FunctionLibrary.isConvert(f)) { return false; } return isConstantConvert(f.getArg(0)); }
/** * Returns the context for a given context function */ static MappingNode getContext(XMLPlannerEnvironment planEnv, Function contextFunction) throws QueryPlannerException { ElementSymbol targetContext = (ElementSymbol)contextFunction.getArg(0); MappingNode contextNode = MappingNode.findNode(planEnv.mappingDoc, targetContext.getName()); if (contextNode == null){ throw new QueryPlannerException(QueryPlugin.Event.TEIID30309, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30309, targetContext)); } return contextNode; }
/** * e1 is of type string, so 1 should be converted to string * @throws Exception */ @Test public void testLookupTypeConversion() throws Exception { String sql = "lookup('pm1.g1', 'e2', 'e1', 1)"; //$NON-NLS-1$ Function f = (Function)getExpression(sql); assertEquals(DataTypeManager.DefaultDataClasses.STRING, f.getArg(3).getType()); }
ex = ((Function)ex).getArg(0);
Class<?> fromType = function.getArg(0).getType(); Class<?> targetType = function.getType(); if (fromType == targetType) {
return; if (!(obj.getArg(1) instanceof Constant)) { markInvalid(obj, obj.getName() + " non-literal parse format function not supported by source"); //$NON-NLS-1$ return; Constant c = (Constant)obj.getArg(1); if (c.isMultiValued()) { markInvalid(obj, obj.getName() + " non-literal parse format function not supported by source"); //$NON-NLS-1$
public void testExecParamFunction() { StoredProcedure exec = new StoredProcedure(); exec.setProcedureName("pm1.proc1"); //$NON-NLS-1$ exec.setProcedureID("proc"); //$NON-NLS-1$ Function f = new Function("length", new Expression[] { exampleElement(true, 1) }); //$NON-NLS-1$ SPParameter param1 = new SPParameter(1, f); exec.setParameter(param1); // Run symbol mapper StaticSymbolMappingVisitor visitor = new StaticSymbolMappingVisitor(getSymbolMap()); DeepPreOrderNavigator.doVisit(exec, visitor); // Check that element got switched Function afterFunc = (Function) param1.getExpression(); assertEquals("Stored proc param did not get mapped correctly: ", exampleElement(false, 1), afterFunc.getArg(0)); //$NON-NLS-1$ }