public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
this.functionLibrary = new FunctionLibrary(systemFunctions); } else { this.functionLibrary = new FunctionLibrary(systemFunctions, functionTrees.toArray(new FunctionTree[functionTrees.size()]));
this.functionLibrary = new FunctionLibrary(systemFunctions); } else { this.functionLibrary = new FunctionLibrary(systemFunctions, functionTrees.toArray(new FunctionTree[functionTrees.size()]));
this.functionLibrary = new FunctionLibrary(systemFunctions); } else { this.functionLibrary = new FunctionLibrary(systemFunctions, functionTrees.toArray(new FunctionTree[functionTrees.size()]));
public void addUDF(String schema, Collection<FunctionMethod> methods) { if (methods == null || methods.isEmpty()) { return; } this.functions.add(new FunctionTree(schema, new UDFSource(methods))); SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager(); functionLibrary = new FunctionLibrary(sfm.getSystemFunctions(), this.functions.toArray(new FunctionTree[this.functions.size()])); }
@Test public void testVarbinary() throws Exception { FunctionMethod method = new FunctionMethod( "dummy", null, null, PushDown.CANNOT_PUSHDOWN, TestFunctionTree.class.getName(), "toString", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Arrays.asList(new FunctionParameter("in", DataTypeManager.DefaultDataTypes.VARBINARY)), //$NON-NLS-1$ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$ true, Determinism.DETERMINISTIC); FunctionTree sys = RealMetadataFactory.SFM.getSystemFunctions(); FunctionLibrary fl = new FunctionLibrary(sys, new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); FunctionDescriptor fd = fl.findFunction("dummy", new Class<?>[] {DataTypeManager.DefaultDataClasses.VARBINARY}); String hello = "hello"; assertEquals(hello, fd.invokeFunction(new Object[] {new BinaryType(hello.getBytes())}, null, null)); }
@Test public void testMultiPartName() throws Exception { FunctionMethod method = new FunctionMethod( "x.y.dummy", null, null, PushDown.CANNOT_PUSHDOWN, TestFunctionTree.class.getName(), "toString", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ Arrays.asList(new FunctionParameter("in", DataTypeManager.DefaultDataTypes.VARBINARY)), //$NON-NLS-1$ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$ true, Determinism.DETERMINISTIC); FunctionTree sys = RealMetadataFactory.SFM.getSystemFunctions(); FunctionLibrary fl = new FunctionLibrary(sys, new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); assertNotNull(fl.findFunction("dummy", new Class<?>[] {DataTypeManager.DefaultDataClasses.VARBINARY})); assertNotNull(fl.findFunction("y.dummy", new Class<?>[] {DataTypeManager.DefaultDataClasses.VARBINARY})); }
@Test public void testMultiPartNameSystemConflict() throws Exception { FunctionMethod method = new FunctionMethod( "x.concat", null, null, PushDown.MUST_PUSHDOWN, null, null, Arrays.asList(new FunctionParameter("in", DataTypeManager.DefaultDataTypes.STRING), new FunctionParameter("in", DataTypeManager.DefaultDataTypes.STRING)), //$NON-NLS-1$ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$ true, Determinism.DETERMINISTIC); FunctionTree sys = RealMetadataFactory.SFM.getSystemFunctions(); FunctionLibrary fl = new FunctionLibrary(sys, new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fl.determineNecessaryConversions("concat", DataTypeManager.DefaultDataClasses.STRING, new Expression[] {new Constant(1), new Constant(2)}, new Class[] {DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER},false); }
new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)))); new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true)); fail(); } catch (TeiidRuntimeException e) { new FunctionLibrary(RealMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true));