@Override protected Collection<? extends FunctionParameter> getChildren(final FunctionMethod parent, CommandContext cc) { ArrayList<FunctionParameter> result = new ArrayList<FunctionParameter>(parent.getInputParameters().size() + 1); result.addAll(parent.getInputParameters()); result.add(parent.getOutputParameter()); return result; }
@Override protected Collection<? extends FunctionParameter> getChildren(final FunctionMethod parent, CommandContext cc) { ArrayList<FunctionParameter> result = new ArrayList<FunctionParameter>(parent.getInputParameters().size() + 1); result.addAll(parent.getInputParameters()); result.add(parent.getOutputParameter()); return result; }
@Override protected Collection<? extends FunctionParameter> getChildren(final FunctionMethod parent, CommandContext cc) { ArrayList<FunctionParameter> result = new ArrayList<FunctionParameter>(parent.getInputParameters().size() + 1); result.addAll(parent.getInputParameters()); result.add(parent.getOutputParameter()); return result; }
FunctionParameter getParameter(String paramName, FunctionMethod func) throws MetadataException { List<FunctionParameter> params = func.getInputParameters(); for (FunctionParameter param:params) { if (param.getName().equalsIgnoreCase(paramName)) { return param; } } throw new MetadataException(QueryPlugin.Util.getString("SQLParser.alter_function_param_doesnot_exist", paramName, func.getName())); //$NON-NLS-1$ }
FunctionParameter getParameter(String paramName, FunctionMethod func) throws MetadataException { List<FunctionParameter> params = func.getInputParameters(); for (FunctionParameter param:params) { if (param.getName().equalsIgnoreCase(paramName)) { return param; } } throw new MetadataException(QueryPlugin.Util.getString("SQLParser.alter_function_param_doesnot_exist", paramName, func.getName())); //$NON-NLS-1$ }
FunctionParameter getParameter(String paramName, FunctionMethod func) throws MetadataException { List<FunctionParameter> params = func.getInputParameters(); for (FunctionParameter param:params) { if (param.getName().equalsIgnoreCase(paramName)) { return param; } } throw new MetadataException(QueryPlugin.Util.getString("SQLParser.alter_function_param_doesnot_exist", paramName, func.getName())); //$NON-NLS-1$ }
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); }
private void setFunctionMethodTypes(FunctionMethod function) { FunctionParameter outputParameter = function.getOutputParameter(); if (outputParameter != null) { setDataType(outputParameter.getRuntimeType(), outputParameter, dataTypes, outputParameter.getNullType() == NullType.Nullable); } for (FunctionParameter param : function.getInputParameters()) { setDataType(param.getRuntimeType(), param, dataTypes, param.getNullType() == NullType.Nullable); } }
private FunctionMethod addFunction(Method method, TeiidFunction f, String name) { FunctionMethod func = MetadataFactory.createFunctionFromMethod(name, method); func.setDescription(QueryPlugin.Util.getString(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_description"))); //$NON-NLS-1$ //$NON-NLS-2$ func.setCategory(f.category()); for (int i = 0; i < func.getInputParameterCount(); i++) { func.getInputParameters().get(i).setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_param" + (i+1))); //$NON-NLS-1$ //$NON-NLS-2$ } func.getOutputParameter().setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_result")); //$NON-NLS-1$ //$NON-NLS-2$ if (f.nullOnNull()) { func.setNullOnNull(true); } func.setDeterminism(f.determinism()); func.setPushdown(f.pushdown()); functions.add(func); return func; }
private FunctionMethod addFunction(Method method, TeiidFunction f, String name) { FunctionMethod func = MetadataFactory.createFunctionFromMethod(name, method); func.setDescription(QueryPlugin.Util.getString(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_description"))); //$NON-NLS-1$ //$NON-NLS-2$ func.setCategory(f.category()); for (int i = 0; i < func.getInputParameterCount(); i++) { func.getInputParameters().get(i).setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_param" + (i+1))); //$NON-NLS-1$ //$NON-NLS-2$ } func.getOutputParameter().setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_result")); //$NON-NLS-1$ //$NON-NLS-2$ if (f.nullOnNull()) { func.setNullOnNull(true); } func.setDeterminism(f.determinism()); func.setPushdown(f.pushdown()); functions.add(func); return func; }
private FunctionMethod addFunction(Method method, TeiidFunction f, String name) { FunctionMethod func = MetadataFactory.createFunctionFromMethod(name, method); func.setDescription(QueryPlugin.Util.getString(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_description"))); //$NON-NLS-1$ //$NON-NLS-2$ func.setCategory(f.category()); for (int i = 0; i < func.getInputParameterCount(); i++) { func.getInputParameters().get(i).setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_param" + (i+1))); //$NON-NLS-1$ //$NON-NLS-2$ } func.getOutputParameter().setDescription(QueryPlugin.Util.getString("SystemSource." + name.toLowerCase() + "_result")); //$NON-NLS-1$ //$NON-NLS-2$ if (f.nullOnNull()) { func.setNullOnNull(true); } func.setDeterminism(f.determinism()); func.setPushdown(f.pushdown()); functions.add(func); return func; }
@Test public void testFunctionMetadata() throws Exception { TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/TEIIDDES992_VDB.vdb"); Map<String, FunctionMethod> functions = tm.getMetadataStore().getSchema("TEIIDDES992").getFunctions(); assertEquals(1, functions.size()); FunctionMethod fm = functions.values().iterator().next(); assertEquals("mmuuid:5c2cede9-0e18-4e4c-a531-34507abf0ff8", fm.getUUID()); assertEquals("sampleFunction", fm.getName()); assertEquals(1, fm.getInputParameters().size()); assertEquals("mmuuid:f9ded2ae-9652-414e-b5a9-74185f8703c0", fm.getOutputParameter().getUUID()); assertNotNull(fm.getInputParameters().get(0).getParent()); }
@Test public void testMixedCaseTypes() throws Exception { String ddl = "CREATE FUNCTION SourceFunc(flag Boolean) RETURNS varchaR options (UUID 'z')"; Schema s = helpParse(ddl, "model").getSchema(); FunctionMethod fm = s.getFunction("z"); assertEquals("boolean", fm.getInputParameters().get(0).getRuntimeType()); }
@Test(expected=MetadataException.class) public void testInvalidFunctionBody() throws Exception { String ddl = "CREATE FOREIGN FUNCTION SourceFunc(flag boolean) RETURNS varchar AS SELECT 'a';"; Schema s = helpParse(ddl, "model").getSchema(); FunctionMethod fm = s.getFunction("z"); assertTrue( fm.getInputParameters().get(0).isVarArg()); }
@Test(expected=MetadataException.class) public void testInvalidProcedureBody() throws Exception { String ddl = "CREATE FOREIGN PROCEDURE SourceFunc(flag boolean) RETURNS varchar AS SELECT 'a';"; Schema s = helpParse(ddl, "model").getSchema(); FunctionMethod fm = s.getFunction("z"); assertTrue( fm.getInputParameters().get(0).isVarArg()); }
@Test public void testVarArgs() throws Exception { String ddl = "CREATE FUNCTION SourceFunc(flag boolean) RETURNS varchar options (varargs 'true', UUID 'z')"; Schema s = helpParse(ddl, "model").getSchema(); FunctionMethod fm = s.getFunction("z"); assertTrue( fm.getInputParameters().get(0).isVarArg()); }
private void assignOids(Schema schema, TreeMap<String, RecordHolder> map) { addOid(schema, map); for (Table table : schema.getTables().values()) { addOid(table, map); addOids(table.getColumns(), map); addOids(table.getAllKeys(), map); } for (Procedure proc : schema.getProcedures().values()) { addOid(proc, map); addOids(proc.getParameters(), map); if (proc.getResultSet() != null) { addOids(proc.getResultSet().getColumns(), map); } } for (FunctionMethod func : schema.getFunctions().values()) { addOid(func, map); addOids(func.getInputParameters(), map); addOid(func.getOutputParameter(), map); } }
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); }