Teiid Springboot starter file datasource

93 views Asked by At

Using Teiid Springboot I would like to consume xml files from disk. I used to work with the old EAP/Wildfly Teiid project and the way to solve this was to use a resource adapter and then call a procedure to read the data.

With Springboot what steps do I need to take to create a datasource/resource adapter that can be used in my DDL VDB. I already had a look at the FTP example below, so my assumption would be to create a FileConnectionFactory: https://github.com/teiid/teiid-spring-boot/tree/master/samples/ftp However, there is no use of a DDL file and my preference is to parse the XML in the DDL (unless there is a better way to expose the this data in my DDL).

1

There are 1 answers

0
Ramesh Reddy On BEST ANSWER

When using DDL based VDB, you can define the file-based connection by supplying the following properties in the application.properties

spring.teiid.file.foo.parent-directory=path/to/myfile

where foo is your file resource name, which needs to be used in VDB, for example: (accounts is the name given for schema)

CREATE SERVER foo FOREIGN DATA WRAPPER file;
CREATE SCHEMA accounts SERVER foo;

then in a view transformation, you can use the above schema and read the file as

create view something(...) AS
  select x.* from 
    (exec accounts.getTextFiles()) f, 
    xmltable('/a' PASSING xmlparse(document f.file) COLUMNS first string, second integer) x

For more details about using xmltable see http://teiid.github.io/teiid-documents/master/content/reference/r_xmltable.html