如何为Presto和InfluxDB创建自定义连接器

时间:2017-12-07 09:44:29

标签: influxdb presto

我正在尝试为Presto和InfluxDB创建自定义连接器,以便Presto可以在InfluxDB上运行SQL查询。有没有这种连接器可用的例子?

Connectors are the source of all data for queries in Presto. Even if your data source doesn’t have underlying tables backing it, as long as you adapt your data source to the API expected by Presto, you can write queries against this data.

我发现编写连接器的唯一文档是:     https://prestodb.io/docs/current/develop/example-http.html

如果有人有其他例子,请你分享一下吗?

2 个答案:

答案 0 :(得分:7)

presto源树中有多个连接器。

当您连接到具有JDBC驱动程序的数据源时(可能不是您的情况),扩展<?php defined('BASEPATH') OR exit('No direct script access allowed'); $active_group = 'default'; $query_builder = TRUE; $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'ausername', 'password' => 'apassword', 'database' => 'adatabase', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE ); $db['second_database'] = array( 'dsn' => '', 'hostname' => 'aaa.bbb-east-1.rds.amazonaws.com', 'port' => '14733', 'username' => 'aa', 'password' => 'apassword1', 'database' => 'adatabase1', 'dbdriver' => 'sqlsrv', 'dbprefix' => '', 'pconnect' => FALSE, 'db_debug' => (ENVIRONMENT !== 'production'), 'cache_on' => FALSE, 'cachedir' => '', 'char_set' => 'utf8', 'dbcollat' => 'utf8_general_ci', 'swap_pre' => '', 'encrypt' => FALSE, 'compress' => FALSE, 'stricton' => FALSE, 'failover' => array(), 'save_queries' => TRUE ); 驱动程序几乎可以满足您的所有需求。请参阅示例https://github.com/prestosql/presto/tree/master/presto-postgresql

当您连接到不支持JDBC的数据源时(或者需要更多可能presto-base-jdbc),您需要实现所有相关的连接器接口。除了Java接口之外,没有其他好的文档。源代码,但您可以按照例如https://github.com/prestosql/presto/tree/master/presto-cassandrahttps://github.com/prestosql/presto/tree/master/presto-accumulo

另一个选择是Greg Leclercq建议实施Thrift连接器。查看他的answer了解路线。

答案 1 :(得分:1)

如果您更喜欢用Java以外的编程语言编写代码,那么另一个选择是实现Thrift服务并使用Thrift connector