Package org.teiid.query.function

Examples of org.teiid.query.function.FunctionTree


        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
        caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
        caps.setFunctionSupport("xyz", true);         //$NON-NLS-1$
        capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$

        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
       
        
        ProcessorPlan plan = helpPlan(
            "SELECT e1 FROM pm1.g1 WHERE xyz() > 0"//$NON-NLS-1$
View Full Code Here


 
  private static TransformationMetadata buildTransformationMetaData(VDBMetaData vdb, LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores, UDFMetaData udf, FunctionTree systemFunctions, MetadataStore[] additionalStores) {
    Collection <FunctionTree> udfs = new ArrayList<FunctionTree>();
    if (udf != null) {     
      for (Map.Entry<String, Collection<FunctionMethod>> entry : udf.getFunctions().entrySet()) {
        udfs.add(new FunctionTree(entry.getKey(), new UDFSource(entry.getValue()), true));
      }
    }
   
    CompositeMetadataStore compositeStore = new CompositeMetadataStore(stores.getStores());
    for (MetadataStore s:additionalStores) {
      compositeStore.addMetadataStore(s);
      for (Schema schema:s.getSchemas().values()) {
        if (!schema.getFunctions().isEmpty()) {
          udfs.add(new FunctionTree(schema.getName(), new UDFSource(schema.getFunctions().values()), true));
        }
      }
    }
   
    TransformationMetadata metadata =  new TransformationMetadata(vdb, compositeStore, visibilityMap, systemFunctions, udfs);
View Full Code Here

      Collection <FunctionMethod> methods = null;
      Collection<FunctionTree> trees = null;
      if (udfFile != null) {
        String schema = FileUtils.getFilenameWithoutExtension(udfFile.getPath());
        methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
        trees = Arrays.asList(new FunctionTree(schema, new UDFSource(methods), true));
      }
      SystemFunctionManager sfm = new SystemFunctionManager();
      vdbmetadata = new TransformationMetadata(null, new CompositeMetadataStore(Arrays.asList(getSystem(), imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(), sfm.getSystemFunctions(), trees);
      VDB_CACHE.put(vdbURL, vdbmetadata);
      return vdbmetadata;
View Full Code Here

      //explicitly denied
        helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", FakeMetadataFactory.example1Cached(), new String[] {"x"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
    }
   
    @Test public void testFunction() throws Exception {
      FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
      helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
        helpTest(exampleAuthSvc2(), "SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$
    }
View Full Code Here

  public void setUDF(final Collection<FunctionMethod> methods) {
    this.metadata = new BasicQueryMetadataWrapper(this.metadata) {
      @Override
      public FunctionLibrary getFunctionLibrary() {
        SystemFunctionManager sfm = new SystemFunctionManager();
        return new FunctionLibrary(sfm.getSystemFunctions(), new FunctionTree("foo", new UDFSource(methods)))//$NON-NLS-1$
      }
    };
  }
View Full Code Here

    @Test public void testRewriteCritSubqueryFalse2() {
        helpTestRewriteCriteria("pm1.g1.e1 < ALL (select 'a' from pm1.g1 where 1=0)", "pm1.g1.e1 IS NOT NULL"); //$NON-NLS-1$ //$NON-NLS-2$
    }
   
  @Test public void testUDFParse() throws Exception {    
        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
    String sql = "parsedate_(pm1.g1.e1) = {d'2001-01-01'}";
        helpTestRewriteCriteria(sql, parseCriteria(sql, metadata), metadata);     
  }
View Full Code Here

    }
   
  @Test public void testNamespacedFunction() throws Exception {    
    String sql = "SELECT namespace.func('e1')  FROM vm1.g1 "; //$NON-NLS-1$

        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource()));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
   
    Query command = (Query) helpParse(sql);
    QueryResolver.resolveCommand(command, metadata);
   
View Full Code Here

        BasicSourceCapabilities caps = new BasicSourceCapabilities();
        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
        caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
        capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$

        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
       
        processPreparedStatement(sql, expected, dataManager, capFinder,
        metadata, Arrays.asList("a    "));       
    }
View Full Code Here

        caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
        caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
        caps.setFunctionSupport("concat", true); //$NON-NLS-1$
        capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$

        FunctionLibrary funcLibrary = new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree("foo", new FakeFunctionMetadataSource(), true));
        FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
       
        processPreparedStatement(sql, expected, dataManager, capFinder,
        metadata, Arrays.asList("a"));
    }     
View Full Code Here

      vdbMetaData.setVersion(1);
      List<FunctionTree> udfs = new ArrayList<FunctionTree>();
      for (Schema schema : metadataStore.getSchemas().values()) {
      vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(), schema.isPhysical()));
      if (!schema.getFunctions().isEmpty()) {
        udfs.add(new FunctionTree(schema.getName(), new UDFSource(schema.getFunctions().values()), true));
      }
    }
      return new TransformationMetadata(vdbMetaData, store, null, FakeMetadataFactory.SFM.getSystemFunctions(), udfs);
  }
View Full Code Here

TOP

Related Classes of org.teiid.query.function.FunctionTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.