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

Use assignments instead of variable name in Elasticsearch #11354

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

assaf2
Copy link
Member

@assaf2 assaf2 commented Mar 7, 2022

No description provided.

@cla-bot cla-bot bot added the cla-signed label Mar 7, 2022
@assaf2 assaf2 requested review from findepi and martint March 7, 2022 16:53
Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Can you add a test?

cc @wendigo

@@ -546,14 +547,16 @@ public ConnectorTableProperties getTableProperties(ConnectorSession session, Con
// TODO Support ESCAPE character when it's pushed down by the engine
if (LIKE_PATTERN_FUNCTION_NAME.equals(call.getFunctionName()) && call.getArguments().size() == 2 &&
call.getArguments().get(0) instanceof Variable && call.getArguments().get(1) instanceof Constant) {
String columnName = ((Variable) call.getArguments().get(0)).getName();
String name = ((Variable) call.getArguments().get(0)).getName();
Copy link
Member

Choose a reason for hiding this comment

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

name -> variableName

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Object pattern = ((Constant) call.getArguments().get(1)).getValue();
if (!newRegexes.containsKey(columnName) && pattern instanceof Slice) {
if (!newRegexes.containsKey(column.getName()) && pattern instanceof Slice) {
Copy link
Member

Choose a reason for hiding this comment

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

Extract columnName variable for readability.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@assaf2
Copy link
Member Author

assaf2 commented Mar 7, 2022

Can you add a test?

cc @wendigo

There is io.trino.plugin.elasticsearch.BaseElasticsearchConnectorTest#testLike. Do you think I should add a test that specifically checks the usage of assignments to io.trino.plugin.elasticsearch.TestElasticsearchMetadata?

@assaf2 assaf2 force-pushed the use-assignments-elasticsearch branch from 08559e0 to 1e09a6b Compare March 7, 2022 17:13
@assaf2 assaf2 requested a review from findepi March 7, 2022 17:13
@findepi
Copy link
Member

findepi commented Mar 8, 2022

There is io.trino.plugin.elasticsearch.BaseElasticsearchConnectorTest#testLike.

I guess the test was not failing before the change, so while it exercises the code, it was not exactly what i was looking for. Anyway, perhaps we don't need that.

@findepi findepi merged commit 9aeb65d into trinodb:master Mar 8, 2022
@github-actions github-actions bot added this to the 373 milestone Mar 8, 2022
@findepi findepi mentioned this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants