Skip to content
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

[FLINK-30702] Add Elasticsearch dialect #67

Closed
wants to merge 4 commits into from

Conversation

grzegorz8
Copy link

@grzegorz8
Copy link
Author

@MartijnVisser Hi! I've fixed code formatting, so I think build can be rerun now. Thanks!

@grzegorz8 grzegorz8 force-pushed the FLINK-30702-attempt2 branch from 9d951cf to 68c4dda Compare November 10, 2023 08:08
@grzegorz8
Copy link
Author

@eskabetxe Could you review the PR, please?

Copy link
Member

@eskabetxe eskabetxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @grzegorz8, thanks for your contribution.
I left some comments

but should be this PR on https://github.com/apache/flink-connector-elasticsearch ??

public ElasticsearchMetadata(ElasticsearchContainer container) {
this.containerHost = container.getHost();
this.containerPort = container.getMappedPort(ELASTIC_PORT);
this.username = USERNAME;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we obtain this from container?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid not. We can only extract password from container envs (ELASTIC_PASSWORD).

CONTAINER.start();

// JDBC plugin is available only in Platinum and Enterprise licenses or in trial.
if (!getClient().trialEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartijnVisser can you validate this? I dont know if by license we can do this.

/** Elasticsearch docker images. */
public interface ElasticsearchImages {

String ELASTICSEARCH_8 = "docker.elastic.co/elasticsearch/elasticsearch:8.8.1";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for that specific version? current on 8.11.1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8.8.1 was the latest one when I created the PR.
Version updated.

&& response.license.type.equals("trial");
}

public void enableTrial() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartijnVisser here comes the real action

<postgres.version>42.5.1</postgres.version>
<oracle.version>21.8.0.0</oracle.version>
<trino.version>418</trino.version>
<byte-buddy.version>1.12.10</byte-buddy.version>
<elasticsearch.version>8.8.1</elasticsearch.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this version? last version is 8.11.1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version updated.

}

@Override
public Optional<String> getUpsertStatement(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if read is the only option for ES, this should be on documentation

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean docs/content/docs/connectors/table/jdbc.md? Which section is the most suitable one?

<postgres.version>42.5.1</postgres.version>
<oracle.version>21.8.0.0</oracle.version>
<trino.version>418</trino.version>
<byte-buddy.version>1.12.10</byte-buddy.version>
<elasticsearch.version>8.11.1</elasticsearch.version>
Copy link
Contributor

@MartijnVisser MartijnVisser Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be really careful about what's included here, since the Elasticsearch dependency that's being references isn't an Apache-compatible license

Code that is licensed solely under the Elastic License 2.0 is found only in the x-pack folder.
https://github.com/elastic/elasticsearch/blob/main/LICENSE.txt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'm not fully aware of all consequences of mixing licences here.

Below I summarize all elastic dependencies which are used:

  • org.elasticsearch.plugin:x-pack-sql-jdbc - Elastic License 2.0 - The dependency has provided scope so it will not be part of the connector "fat-jar". If someone wants to use it, has to add it to classpath/container/etc on their own. Does it make us "safe"?

  • org.elasticsearch.client:elasticsearch-rest-client (https://mvnrepository.com/artifact/org.elasticsearch.client/elasticsearch-rest-client) used with test scope - Apache 2 License - we are safe here.

Copy link
Author

@grzegorz8 grzegorz8 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartijnVisser Hi! What should be done to ensure if adding this dependency (even as "provided") is allowed? The same question for enabling Elastic trial for testing purposes.
Should I create a ticket somewhere? Write to [email protected]? What do you suggest? Or should we already close the PR and corresponding ticket due to incompatible license?

The license is not listed on Category X: https://www.apache.org/legal/resolved.html#category-x (nor in any other). Assuming Elastic License is "Category X", I think we are still safe, since we do not violate the following rules mentioned in the document: "They may not be distributed" and "You may rely on them when they support an optional feature".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should be done to ensure if adding this dependency (even as "provided") is allowed?

I think we should add an enforcer rule to make sure that it's never bundled. Next to that, I think we should make a similar statement in the docs as we've done for RabbitMQ (see https://nightlies.apache.org/flink/flink-docs-master/docs/connectors/datastream/rabbitmq/)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MartijnVisser Both enforcer rule and statement about JDBC driver license have been added.

@grzegorz8
Copy link
Author

Hi @grzegorz8, thanks for your contribution. I left some comments

but should be this PR on https://github.com/apache/flink-connector-elasticsearch ??

I just thought flink-connector-jdbc is the most suitable place - I merely add a JDBC dialect. This repo already contains lots of test utils that are used for elastic dialect as well.

Alternatively, we can add a new module flink-jdbc-dialect (or similar name) to flink-connector-elasticsearch but I'm not sure it is the best idea.

@grzegorz8
Copy link
Author

Due to recent refactoring it was easier to create a new PR: #136
Closing this one.

@grzegorz8 grzegorz8 closed this Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants