3 Replies Latest reply on Aug 15, 2012 1:45 PM by Ivan Chan

    MetaData for Text File

    Ivan Chan Apprentice

      I am looking at Text File example for Teiid embedded version 8.1.  And it seems like the metadata information for text file is  written within the SQL statement.  See below:


      "select stock.* from (call Market_Price.getTextFiles('*.txt')) f, TEXTTABLE(f.file COLUMNS symbol string, price bigdecimal HEADER) stock";


      I am wondering would it be possible to set the MetaData information in FileManagedConnectionFactory instead? 


      METADATA INFO:  (call Market_Price.getTextFiles('*.txt')) f, TEXTTABLE(f.file COLUMNS symbol string, price bigdecimal HEADER) stock


      Teiid can execute a cleaner SQL statement in runtime for text file.  Like below:


      "select stock.* from stock";






        • 1. Re: MetaData for Text File
          Ramesh Reddy Master



          The end result is just like you mentioned, you can call


          "select stock.* from stock"


          ConnectionFactory - Provides the connection to the source and executes the given native query and returns results.


          Translator - Defines the metadata for the source in dynamic scenarios, and provides the translation layer where given Teiid SQL query is converted to a source specific query, which gets passed down to a connection factory. You can also choose to define the metadata in the form of DDL using these https://docs.jboss.org/author/display/teiid81final/DDL+Metadata which the example has done.


          They are divided by their functionality, so you can not define the metadata on the Connection Factory. I think we should add some example queries uses can run to the embedded example.



          1 of 1 people found this helpful
          • 2. Re: MetaData for Text File
            Steven Hawkins Master



            Do you mean the embedded kit example, or the dynamic vdb portfolio example?   


            To further what Ramesh is highlighting about encapsulation you can check the examples under docs/teiid/examples.  If you are using a dynamic vdb,  see the dyanmicvdb-twitter example for a vdb.xml that specifies a virtual procedure in ddl.  You can do the same thing, but for your stock view.  If you are using Teiid embedded, then see the embedded-portfolio example TeiidEmbeddedPortfolio class where there is a setSchemaText call on the portfolio schema/model.  You can then see that there is a query executed against the portfolio view at the end of the main method.



            • 3. Re: MetaData for Text File
              Ivan Chan Apprentice

              Thank you, Steven and Ramesh.  Yes, I am using Teiid embedded version.  I will take a look at TeiidEmbeddedPortolio class.  Thanks for your help!