-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Influx Connector #2397
Influx Connector #2397
Conversation
…e dependency problems
presto-influx/src/test/java/io/prestosql/plugin/influx/InfluxPluginTest.java
Outdated
Show resolved
Hide resolved
presto-influx/src/test/java/io/prestosql/plugin/influx/InfluxQueryTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left only basic comments. This is codestyle guidleline in this project if you haven't yet read it. https://github.com/prestosql/presto#code-style
presto-influx/src/test/java/io/prestosql/plugin/influx/TestingInfluxServer.java
Outdated
Show resolved
Hide resolved
presto-influx/src/test/java/io/prestosql/plugin/influx/TestingInfluxServer.java
Outdated
Show resolved
Hide resolved
presto-influx/src/test/java/io/prestosql/plugin/influx/TestingInfluxServer.java
Outdated
Show resolved
Hide resolved
presto-influx/src/test/java/io/prestosql/plugin/influx/TestInfluxQL.java
Outdated
Show resolved
Hide resolved
presto-influx/src/main/java/io/prestosql/plugin/influx/InfluxHttp.java
Outdated
Show resolved
Hide resolved
presto-influx/src/main/java/io/prestosql/plugin/influx/InfluxHttp.java
Outdated
Show resolved
Hide resolved
Before starting more detailed reviews, let's talk if we really want to use okhttp instead of the existing library |
One issue is dependency versions. Adding this to the pom:
Will cause okhttp3 version conflicts with the rest of presto. How would we best solve that? The other issue is how to build the query string. At the moment, this connector in the MR is building that manually with a custom InfluxQL class. However, obviously it would smell less if we could use the QueryBuilder offered by the influx java lib instead. However, the QueryBuilder https://github.com/influxdata/influxdb-java/blob/master/QUERY_BUILDER.md doesn't support column names that need quoting. Deep in the implementation the columns are appended to a StringBuilder unescaped in https://github.com/influxdata/influxdb-java/blob/master/src/main/java/org/influxdb/querybuilder/Appender.java#L76 and the API doc examples rely on and abuse this so it probably can't ever be added. Another issue is the quoting of parameters. Newer versions of the influx java library do support ? to denote a parameter, rather like JDBC's PreparedStatement. However, the influx java library always passes these parameters to the influx server, even though early versions of influx didn't support this feature. So, if we sort out the dependency problem, it looks like we'd still be building our own InfluxQL strings manually rather than using a tried and tested QueryBuilder. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to switch to the official library later, but I left initial comments for http client.
I suppose influxdb
is the exected name (≠influx) as mongodb
. This is not a huge problem, but it will affect config properties.
private final OkHttpClient httpClient; | ||
private final String baseUrl; | ||
// the various metadata are cached for a configurable number of milliseconds so we don't hammer the server | ||
private final CachedMetaData<Map<String, String>> retentionPolicies; // schema name (lower-case) -> retention policy (case-sensitive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, we use guava for cache. You can see the existing code in MongoSession
While I think it worth to cache table definitions, I'm not sure if we should store schema and table names. Are those operations slow in InfluxDB?
// Influx tracks the tags in each measurement, but not which retention-policy they are used in | ||
private Map<String, InfluxColumn> getTags(String tableName) | ||
{ | ||
return tagKeys.computeIfAbsent(tableName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method and getFields are too nested. Please try to avoid it.
|
||
public List<InfluxColumn> getColumns(String schemaName, String tableName) | ||
{ | ||
List<InfluxColumn> columns = InfluxTpchTestSupport.getColumns(config.getDatabase(), schemaName, tableName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood this is the temporally hack to run TPCH test. Please correct me if my understanding is wrong.
Cassandra connector has the same behavior, the column orders is arranged automatically. Then, we added extra information to hold the expected orders. Could you try adding the same feature? You can refer CassandraSession
class.
if (series == null) { | ||
return Collections.emptyMap(); | ||
} | ||
InfluxError.GENERAL.check(series.getNodeType().equals(JsonNodeType.ARRAY), "expecting an array, not " + series, query); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid using InfluxError check and fail methods. We can use checkArgument method, PrestoException class and so on.
public InfluxQueryRunner() | ||
throws Exception | ||
{ | ||
dockerContainer = new InfluxDBContainer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract dockerContainer
from this class. You can refer to TestingMySqlServer
class.
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); | ||
assertInstanceOf(factory, InfluxConnectorFactory.class); | ||
|
||
Connector c = factory.create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid abbreviations.
Connector c = factory.create( | |
Connector connector = factory.create( |
|
||
// from is a reserved word so must be quoted | ||
test.addIdentifier("frOm").append(" = ").add("to"); | ||
assertEquals(test.toString(), "\"frOm\" = 'to'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add more test cases?
|
||
public class InfluxClient | ||
{ | ||
final Logger logger; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it private static final
``influx.database=`` The database name must be specified. Each instance of the connector | ||
can only connect to a single database on a server | ||
``influx.username=`` Optional | ||
``influx.password=`` Option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo
Co-Authored-By: Yuya Ebihara <ebyhry@gmail.com>
Hi is this pull request is still on the going? |
I subscribed to this pull request but I just wanted to echo @ofekby 's enthusiasm and interest in the final product. Thank you for your work. (I'd maybe try building what you have, but I'd rather wait until it's official.) |
FWIW, I built an image from Will's source - currently at Presto version 330-SNAPSHOT - and it works beautifully. I hope this can get past the finish line and merged into the official image. It's a great connector. UPDATE (13-May-2020): In my development environment, I forked a version of the PR, merged it with Presto 333, added some logging (the query & url strings), and added a new |
Hi Is this connector for influxdb available for download ? |
Hi By when will this connector be officially available? |
@williame hello, Does connector support influxdb now? |
👋🏻 This PR looks really interesting. It looks like there's a lot of demand for it. @williame, are you still interested in working on this? @cpard, any interest in looking into this feature? Unfortunately, it looks like this is inactive and nobody is working on it. We're working on closing out old and inactive PRs, so if you're too busy or this has too many merge conflicts to be worth picking back up, we'll be making another pass to close it out in a few weeks. |
Influx is a noSQL time-series database. https://www.influxdata.com/