public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
public FunctionLibrary getSystemFunctionLibrary() { return new FunctionLibrary(getSystemFunctions()); }
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()])); }
systemStore.addDataTypes(typeMap); loadSchema(vdb, p, "SYSADMIN", parser).mergeInto(systemStore); //$NON-NLS-1$ TransformationMetadata tm = new TransformationMetadata(vdb, new CompositeMetadataStore(systemStore), null, systemFunctionManager.getSystemFunctions(), null); vdb.addAttchment(QueryMetadataInterface.class, tm); MetadataValidator validator = new MetadataValidator(this.typeMap, parser);
systemStore.addDataTypes(typeMap); loadSchema(vdb, p, "SYSADMIN", parser).mergeInto(systemStore); //$NON-NLS-1$ TransformationMetadata tm = new TransformationMetadata(vdb, new CompositeMetadataStore(systemStore), null, systemFunctionManager.getSystemFunctions(), null); vdb.addAttchment(QueryMetadataInterface.class, tm); MetadataValidator validator = new MetadataValidator(this.typeMap, parser);
systemStore.addDataTypes(typeMap); loadSchema(vdb, p, "SYSADMIN", parser).mergeInto(systemStore); //$NON-NLS-1$ TransformationMetadata tm = new TransformationMetadata(vdb, new CompositeMetadataStore(systemStore), null, systemFunctionManager.getSystemFunctions(), null); vdb.addAttchment(QueryMetadataInterface.class, tm); MetadataValidator validator = new MetadataValidator(this.typeMap, parser);
this.systemFunctionManager.getSystemFunctions(), cmr, this, stores); lock.lock(); try {
private void buildTransformationMetadata() { TransformationMetadata metadata = new TransformationMetadata(this.vdb, new CompositeMetadataStore(this.store), null, SFM.getSystemFunctions(), null); this.vdb.addAttchment(QueryMetadataInterface.class, metadata); this.vdb.addAttchment(TransformationMetadata.class, metadata); }
@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)); }
public static TransformationMetadata createTransformationMetadata(CompositeMetadataStore store, String vdbName, Properties vdbProperties, FunctionTree... functionModels) { VDBMetaData vdbMetaData = new VDBMetaData(); vdbMetaData.setName(vdbName); //$NON-NLS-1$ vdbMetaData.setVersion(1); if (vdbProperties != null) { vdbMetaData.setProperties(vdbProperties); } List<FunctionTree> udfs = new ArrayList<FunctionTree>(); udfs.addAll(Arrays.asList(functionModels)); for (Schema schema : store.getSchemas().values()) { vdbMetaData.addModel(RealMetadataFactory.createModel(schema.getName(), schema.isPhysical())); if (!schema.getFunctions().isEmpty()) { udfs.add(new FunctionTree(schema.getName(), new UDFSource(schema.getFunctions().values()), true)); } if (!schema.getProcedures().isEmpty()) { FunctionTree ft = FunctionTree.getFunctionProcedures(schema); if (ft != null) { udfs.add(ft); } } } TransformationMetadata metadata = new TransformationMetadata(vdbMetaData, store, null, SFM.getSystemFunctions(), udfs); vdbMetaData.addAttchment(TransformationMetadata.class, metadata); vdbMetaData.addAttchment(QueryMetadataInterface.class, metadata); return metadata; }
@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})); }
vdbmetadata = new TransformationMetadata(vdb, new CompositeMetadataStore(Arrays.asList(SystemMetadata.getInstance().getSystemStore(), imf.store)), imf.resources.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), trees); VDB_CACHE.put(vdbURL, vdbmetadata); return vdbmetadata;
vdb.addModel(buildModel("y")); return new TransformationMetadata(vdb, cms, resources, RealMetadataFactory.SFM.getSystemFunctions(), null);
vdb.addModel(model2); TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null); Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$ assertEquals(2, result.size()); tm = new TransformationMetadata(vdb, cms, null, RealMetadataFactory.SFM.getSystemFunctions(), null); result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$ assertEquals(1, result.size());
@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));
CompositeMetadataStore compositeStore = new CompositeMetadataStore(vdbMetadataStore); final TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore, null, getVDBRepository().getSystemFunctionManager().getSystemFunctions(), null);