Teiid Springboot入门文件数据源

问题描述

使用Teiid Springboot,我想使用磁盘上的xml文件。我曾经使用过旧的EAP / Wildfly Teiid项目,解决此问题的方法是使用资源适配器,然后调用一个过程来读取数据。

使用Springboot,我需要采取什么步骤来创建可在DDL VDB中使用的数据源/资源适配器。 我已经看过下面的FTP示例,因此我的假设是创建一个FileConnectionFactory: https://github.com/teiid/teiid-spring-boot/tree/master/samples/ftp 但是,没有使用DDL文件,我的首选是解析DDL中的XML(除非有更好的方法在DDL中公开此数据)。

解决方法

使用基于DDL的VDB时,您可以通过在application.properties中提供以下属性来定义基于文件的连接

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

其中foo是您的文件资源名称,需要在VDB中使用,例如:(accounts是为架构指定的名称)

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

然后在视图转换中,您可以使用上述架构并将文件读取为

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

有关使用xmltable的更多详细信息,请参见http://teiid.github.io/teiid-documents/master/content/reference/r_xmltable.html

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...