Skip to content

SQL: DATABASE() and USER() system functions #35946

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

Merged
merged 12 commits into from
Nov 28, 2018
Merged

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Nov 27, 2018

This PR adds two system functions to SQL and is fixing #35863.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

}

private String randomMode() {
return randomFrom("plain", "jdbc", "");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the Mode enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mode is not visible in the qa project.

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

Looks good! Left some comments.


import static org.elasticsearch.xpack.sql.qa.rest.RestSqlTestCase.columnInfo;

public class UserFunctionIT extends ESRestTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests! I have some questions/comments though:

  1. Maybe add a test that USER() is used in WHERE clause.
  2. Have a test with null user
  3. What happens if somehow 2 test methods attempt to create the same user? Maybe we need to delete them after each method is run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added tests with WHERE. null user is handled in https://github.com/elastic/elasticsearch/pull/35946/files#diff-36793f91ca7279a48976a3247c18272fR32. Good point about clashing users, so I've changed the way the usernames are managed.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

Left some minor comments, looks good otherwise.

@astefan
Copy link
Contributor Author

astefan commented Nov 28, 2018

@costin @matriv Thank you for your reviews. Pushed few more commits, if you can have another look. Thanks.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM

import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.xpack.core.security.SecurityContext;

class Transports {
Copy link
Contributor

Choose a reason for hiding this comment

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

can also be final with a private constructor

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

LGTM! Left a minor stylistic comment

@astefan astefan merged commit aabff73 into elastic:master Nov 28, 2018
@astefan astefan deleted the 35863_fix branch November 28, 2018 13:20
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.

5 participants