/** * Add a function with the given name to the model. * @param name * @return * @throws MetadataException */ public FunctionMethod addFunction(String name) { FunctionMethod function = new FunctionMethod(); function.setName(name); setUUID(function); this.schema.addFunction(function); return function; }
/** * Add a function with the given name to the model. * @param name * @return * @throws MetadataException */ public FunctionMethod addFunction(String name, String returnType, String... paramTypes) { FunctionMethod function = FunctionMethod.createFunctionMethod(name, null, null, returnType, paramTypes); setFunctionMethodTypes(function); function.setPushdown(PushDown.MUST_PUSHDOWN); setUUID(function); schema.addFunction(function); return function; }
/** * Adds a non-pushdown function based upon the given {@link Method}. * @param name * @param method * @return * @throws MetadataException */ public FunctionMethod addFunction(String name, Method method) { FunctionMethod func = createFunctionFromMethod(name, method); setFunctionMethodTypes(func); setUUID(func); getSchema().addFunction(func); return func; }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
static FunctionMethod replaceProcedureWithFunction(MetadataFactory factory, Procedure proc) throws MetadataException { if (proc.isFunction() && proc.getQueryPlan() != null) { return null; } FunctionMethod method = createFunctionMethod(proc); //remove the old proc factory.getSchema().getResolvingOrder().remove(factory.getSchema().getResolvingOrder().size() - 1); factory.getSchema().getProcedures().remove(proc.getName()); factory.getSchema().addFunction(method); return method; }
public void addFunction(FunctionMethod functionMethod) { functionMethod.setParent(this.schema); setUUID(functionMethod); for (FunctionParameter param : functionMethod.getInputParameters()) { setUUID(param); } setUUID(functionMethod.getOutputParameter()); this.schema.addFunction(functionMethod); }
@Test public void testFunction() throws Exception { Schema s = new Schema(); s.addFunction(MetadataFactory.createFunctionFromMethod("x", TestDDLStringVisitor.class.getMethod("someMethod", int.class))); String metadataDDL = DDLStringVisitor.getDDLString(s, null, null); assertEquals("CREATE VIRTUAL FUNCTION x(param1 integer) RETURNS string[]" + "\nOPTIONS (NAMEINSOURCE 'x', JAVA_CLASS 'org.teiid.query.metadata.TestDDLStringVisitor', JAVA_METHOD 'someMethod');", metadataDDL); }
public void functionCreated(FunctionMethod function) { if (!assertInEditMode(Mode.SCHEMA)) { return; } assertGrant(Grant.Permission.Privilege.CREATE, Database.ResourceType.FUNCTION, function); Schema s = getCurrentSchema(); setUUID(s.getUUID(), function); for (FunctionParameter param : function.getInputParameters()) { setUUID(s.getUUID(), param); } setUUID(s.getUUID(), function.getOutputParameter()); s.addFunction(function); }
public void functionCreated(FunctionMethod function) { if (!assertInEditMode(Mode.SCHEMA)) { return; } assertGrant(Grant.Permission.Privilege.CREATE, Database.ResourceType.FUNCTION, function); Schema s = getCurrentSchema(); setUUID(s.getUUID(), function); for (FunctionParameter param : function.getInputParameters()) { setUUID(s.getUUID(), param); } setUUID(s.getUUID(), function.getOutputParameter()); s.addFunction(function); }
public void functionCreated(FunctionMethod function) { if (!assertInEditMode(Mode.SCHEMA)) { return; } assertGrant(Grant.Permission.Privilege.CREATE, Database.ResourceType.FUNCTION, function); Schema s = getCurrentSchema(); setUUID(s.getUUID(), function); for (FunctionParameter param : function.getInputParameters()) { setUUID(s.getUUID(), param); } setUUID(s.getUUID(), function.getOutputParameter()); s.addFunction(function); }
function.setPushdown(PushDown.CAN_PUSHDOWN); model.addFunction(function); continue;
function.setPushdown(PushDown.CAN_PUSHDOWN); model.addFunction(function); continue;
pm1.addFunction(new FakeFunctionMetadataSource().getFunctionMethods().iterator().next());
bqt1.addFunction(new FunctionMethod("reverse", "reverse", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ new FunctionParameter[] {new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$