SQL: Lowercase es data type (mapping) returned from SQL Commands (#37531)
To follow the ES convention, convert the es data type, returned as column `mapping` from SQL Commands, to lowercase. Fixes: #37521
This commit is contained in:
parent
19d2c29ca6
commit
2cf4b1863f
|
@ -391,9 +391,9 @@ public abstract class SqlSecurityTestCase extends ESRestTestCase {
|
|||
|
||||
public void testDescribeWorksAsAdmin() throws Exception {
|
||||
Map<String, List<String>> expected = new TreeMap<>();
|
||||
expected.put("a", asList("BIGINT", "LONG"));
|
||||
expected.put("b", asList("BIGINT", "LONG"));
|
||||
expected.put("c", asList("BIGINT", "LONG"));
|
||||
expected.put("a", asList("BIGINT", "long"));
|
||||
expected.put("b", asList("BIGINT", "long"));
|
||||
expected.put("c", asList("BIGINT", "long"));
|
||||
actions.expectDescribe(expected, null);
|
||||
createAuditLogAsserter()
|
||||
.expectSqlCompositeActionFieldCaps("test_admin", "test")
|
||||
|
@ -434,7 +434,7 @@ public abstract class SqlSecurityTestCase extends ESRestTestCase {
|
|||
public void testDescribeSingleFieldGranted() throws Exception {
|
||||
createUser("only_a", "read_test_a");
|
||||
|
||||
actions.expectDescribe(singletonMap("a", asList("BIGINT", "LONG")), "only_a");
|
||||
actions.expectDescribe(singletonMap("a", asList("BIGINT", "long")), "only_a");
|
||||
createAuditLogAsserter()
|
||||
.expectSqlCompositeActionFieldCaps("only_a", "test")
|
||||
.assertLogs();
|
||||
|
@ -444,8 +444,8 @@ public abstract class SqlSecurityTestCase extends ESRestTestCase {
|
|||
createUser("not_c", "read_test_a_and_b");
|
||||
|
||||
Map<String, List<String>> expected = new TreeMap<>();
|
||||
expected.put("a", asList("BIGINT", "LONG"));
|
||||
expected.put("b", asList("BIGINT", "LONG"));
|
||||
expected.put("a", asList("BIGINT", "long"));
|
||||
expected.put("b", asList("BIGINT", "long"));
|
||||
actions.expectDescribe(expected, "not_c");
|
||||
createAuditLogAsserter()
|
||||
.expectSqlCompositeActionFieldCaps("not_c", "test")
|
||||
|
|
|
@ -28,27 +28,27 @@ DESCRIBE test_alias;
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
extra |STRUCT |OBJECT
|
||||
extra.info |STRUCT |OBJECT
|
||||
extra.info.gender |VARCHAR |KEYWORD
|
||||
extra_gender |VARCHAR |KEYWORD
|
||||
extra_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
extra |STRUCT |object
|
||||
extra.info |STRUCT |object
|
||||
extra.info.gender |VARCHAR |keyword
|
||||
extra_gender |VARCHAR |keyword
|
||||
extra_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
describePattern
|
||||
|
@ -56,27 +56,27 @@ DESCRIBE "test_*";
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
extra |STRUCT |OBJECT
|
||||
extra.info |STRUCT |OBJECT
|
||||
extra.info.gender |VARCHAR |KEYWORD
|
||||
extra_gender |VARCHAR |KEYWORD
|
||||
extra_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
extra |STRUCT |object
|
||||
extra.info |STRUCT |object
|
||||
extra.info.gender |VARCHAR |keyword
|
||||
extra_gender |VARCHAR |keyword
|
||||
extra_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
showAlias
|
||||
|
@ -115,4 +115,4 @@ gender:s | p1:d
|
|||
|
||||
F | 10099.52
|
||||
M | 10096.0
|
||||
;
|
||||
;
|
||||
|
|
|
@ -228,27 +228,27 @@ DESCRIBE LIKE 'test_emp';
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
extra |STRUCT |OBJECT
|
||||
extra.info |STRUCT |OBJECT
|
||||
extra.info.gender |VARCHAR |KEYWORD
|
||||
extra_gender |VARCHAR |KEYWORD
|
||||
extra_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
extra |STRUCT |object
|
||||
extra.info |STRUCT |object
|
||||
extra.info.gender |VARCHAR |keyword
|
||||
extra_gender |VARCHAR |keyword
|
||||
extra_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
describeMultiLike
|
||||
|
@ -256,27 +256,27 @@ DESCRIBE LIKE 'test_emp%';
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
extra |STRUCT |OBJECT
|
||||
extra.info |STRUCT |OBJECT
|
||||
extra.info.gender |VARCHAR |KEYWORD
|
||||
extra_gender |VARCHAR |KEYWORD
|
||||
extra_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
extra |STRUCT |object
|
||||
extra.info |STRUCT |object
|
||||
extra.info.gender |VARCHAR |keyword
|
||||
extra_gender |VARCHAR |keyword
|
||||
extra_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
describeSimpleIdentifier
|
||||
|
@ -284,22 +284,22 @@ DESCRIBE "test_emp";
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
|
||||
|
@ -310,20 +310,20 @@ DESCRIBE "test_*,-test_alias*";
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
|
|
@ -14,22 +14,22 @@ DESCRIBE emp;
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
|
||||
// end::describeTable
|
||||
;
|
||||
|
@ -53,22 +53,22 @@ SHOW COLUMNS IN emp;
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
|
||||
// end::showColumns
|
||||
;
|
||||
|
|
|
@ -8,22 +8,22 @@ DESCRIBE test_emp;
|
|||
|
||||
column | type | mapping
|
||||
--------------------+---------------+---------------
|
||||
birth_date |TIMESTAMP |DATE
|
||||
dep |STRUCT |NESTED
|
||||
dep.dep_id |VARCHAR |KEYWORD
|
||||
dep.dep_name |VARCHAR |TEXT
|
||||
dep.dep_name.keyword|VARCHAR |KEYWORD
|
||||
dep.from_date |TIMESTAMP |DATE
|
||||
dep.to_date |TIMESTAMP |DATE
|
||||
emp_no |INTEGER |INTEGER
|
||||
first_name |VARCHAR |TEXT
|
||||
first_name.keyword |VARCHAR |KEYWORD
|
||||
gender |VARCHAR |KEYWORD
|
||||
hire_date |TIMESTAMP |DATE
|
||||
languages |TINYINT |BYTE
|
||||
last_name |VARCHAR |TEXT
|
||||
last_name.keyword |VARCHAR |KEYWORD
|
||||
salary |INTEGER |INTEGER
|
||||
birth_date |TIMESTAMP |date
|
||||
dep |STRUCT |nested
|
||||
dep.dep_id |VARCHAR |keyword
|
||||
dep.dep_name |VARCHAR |text
|
||||
dep.dep_name.keyword|VARCHAR |keyword
|
||||
dep.from_date |TIMESTAMP |date
|
||||
dep.to_date |TIMESTAMP |date
|
||||
emp_no |INTEGER |integer
|
||||
first_name |VARCHAR |text
|
||||
first_name.keyword |VARCHAR |keyword
|
||||
gender |VARCHAR |keyword
|
||||
hire_date |TIMESTAMP |date
|
||||
languages |TINYINT |byte
|
||||
last_name |VARCHAR |text
|
||||
last_name.keyword |VARCHAR |keyword
|
||||
salary |INTEGER |integer
|
||||
;
|
||||
|
||||
nestedStar
|
||||
|
@ -296,4 +296,4 @@ SELECT dep.dep_id, dep.dep_name, first_name, emp_no FROM test_emp WHERE emp_no=1
|
|||
dep.dep_id:s | dep.dep_name:s | first_name:s | emp_no:i
|
||||
---------------+----------------+---------------+---------------
|
||||
d007 |Sales |Valter |10099
|
||||
;
|
||||
;
|
||||
|
|
|
@ -81,7 +81,7 @@ public class ShowColumns extends Command {
|
|||
String name = e.getKey();
|
||||
if (dt != null) {
|
||||
// show only fields that exist in ES
|
||||
rows.add(asList(prefix != null ? prefix + "." + name : name, dt.sqlName(), dt.name()));
|
||||
rows.add(asList(prefix != null ? prefix + "." + name : name, dt.sqlName(), dt.esType));
|
||||
if (field.getProperties().isEmpty() == false) {
|
||||
String newPrefix = prefix != null ? prefix + "." + name : name;
|
||||
fillInRows(field.getProperties(), newPrefix, rows);
|
||||
|
@ -109,4 +109,4 @@ public class ShowColumns extends Command {
|
|||
return Objects.equals(index, other.index)
|
||||
&& Objects.equals(pattern, other.pattern);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue