-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Conversation
Extracted a base class for system functions
Pinging @elastic/es-search |
} | ||
|
||
private String randomMode() { | ||
return randomFrom("plain", "jdbc", ""); |
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.
Why not use the Mode enum?
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.
Mode is not visible in the qa
project.
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlQueryAction.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.
Looks good! Left some comments.
- Please also add docs for the new functions.
- Please add the system functions here: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/sql/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcDatabaseMetaData.java#L214 Also add the
IFNULL
function which I somehow missed to add in a previous PR. (ref: https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/system-functions?view=sql-server-2017)
...in/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java
Outdated
Show resolved
Hide resolved
...in/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java
Outdated
Show resolved
Hide resolved
|
||
import static org.elasticsearch.xpack.sql.qa.rest.RestSqlTestCase.columnInfo; | ||
|
||
public class UserFunctionIT extends ESRestTestCase { |
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.
Nice tests! I have some questions/comments though:
- Maybe add a test that USER() is used in WHERE clause.
- Have a test with null user
- What happens if somehow 2 test methods attempt to create the same user? Maybe we need to delete them after each method is run?
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.
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.
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 some minor comments, looks good otherwise.
...in/sql/qa/security/src/test/java/org/elasticsearch/xpack/sql/qa/security/UserFunctionIT.java
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/BaseSystemFunction.java
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/BaseSystemFunction.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlQueryAction.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/session/Configuration.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/analyzer/Analyzer.java
Outdated
Show resolved
Hide resolved
* added the functions to jdbc metadata list of functions * more tests * polishing
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.
LGTM
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.xpack.core.security.SecurityContext; | ||
|
||
class Transports { |
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.
can also be final with a private constructor
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.
LGTM! Left a minor stylistic comment
(cherry picked from commit aabff73)
This PR adds two system functions to SQL and is fixing #35863.