SQL: Fix type and value in SYS TYPES (elastic/x-pack-elasticsearch#3979)
The type of BUFFER_LENGTH needs to be an integer (not NULL) and unsigned indicate the opposite of signed. Change isSigned from Object to primitive Since all the consumer of isSigned expect a primitive, an Object is just causing troubles by being null. Update description table Original commit: elastic/x-pack-elasticsearch@8e1960bdb5
This commit is contained in:
parent
933738c264
commit
8fd361ba83
|
@ -128,11 +128,11 @@ public enum DataType {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns true if value is signed, false if it is unsigned or null if the type doesn't represent a number
|
||||
* Returns true if value is signed, false otherwise (including if the type is not numeric)
|
||||
*/
|
||||
public Boolean isSigned() {
|
||||
public boolean isSigned() {
|
||||
// For now all numeric values that es supports are signed
|
||||
return isNumeric() ? true : null;
|
||||
return isNumeric();
|
||||
}
|
||||
|
||||
public boolean isString() {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class SysColumns extends Command {
|
|||
field("DATA_TYPE", INTEGER),
|
||||
keyword("TYPE_NAME"),
|
||||
field("COLUMN_SIZE", INTEGER),
|
||||
field("BUFFER_LENGTH", NULL),
|
||||
field("BUFFER_LENGTH", INTEGER),
|
||||
field("DECIMAL_DIGITS", INTEGER),
|
||||
field("NUM_PREC_RADIX", INTEGER),
|
||||
field("NULLABLE", INTEGER),
|
||||
|
|
|
@ -81,7 +81,7 @@ public class SysTypes extends Command {
|
|||
// everything is searchable,
|
||||
DatabaseMetaData.typeSearchable,
|
||||
// only numerics are signed
|
||||
t.isSigned(),
|
||||
!t.isSigned(),
|
||||
//no fixed precision scale SQL_FALSE
|
||||
0,
|
||||
null,
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.xpack.sql.expression.function.FunctionRegistry;
|
|||
import org.elasticsearch.xpack.sql.parser.SqlParser;
|
||||
import org.elasticsearch.xpack.sql.plan.logical.command.Command;
|
||||
import org.elasticsearch.xpack.sql.session.SqlSession;
|
||||
import org.elasticsearch.xpack.sql.type.DataType;
|
||||
import org.elasticsearch.xpack.sql.type.EsField;
|
||||
import org.elasticsearch.xpack.sql.type.TypesTests;
|
||||
import org.joda.time.DateTimeZone;
|
||||
|
@ -62,6 +63,9 @@ public class SysParserTests extends ESTestCase {
|
|||
cmd.execute(null, ActionListener.wrap(r -> {
|
||||
assertEquals(19, r.columnCount());
|
||||
assertEquals(17, r.size());
|
||||
assertFalse(r.schema().types().contains(DataType.NULL));
|
||||
// test numeric as signed
|
||||
assertFalse(r.column(9, Boolean.class));
|
||||
|
||||
for (int i = 0; i < r.size(); i++) {
|
||||
assertEquals(names.get(i), r.column(0));
|
||||
|
|
|
@ -5,7 +5,7 @@ CREATE TABLE mock (
|
|||
DATA_TYPE INTEGER,
|
||||
TYPE_NAME VARCHAR,
|
||||
COLUMN_SIZE INTEGER,
|
||||
BUFFER_LENGTH NULL,
|
||||
BUFFER_LENGTH INTEGER,
|
||||
DECIMAL_DIGITS INTEGER,
|
||||
NUM_PREC_RADIX INTEGER,
|
||||
NULLABLE INTEGER,
|
||||
|
@ -23,27 +23,27 @@ CREATE TABLE mock (
|
|||
IS_AUTOINCREMENT VARCHAR,
|
||||
IS_GENERATEDCOLUMN VARCHAR
|
||||
) AS
|
||||
SELECT null, 'test1', 'name', 12, 'TEXT', 0, null, null, null,
|
||||
SELECT null, 'test1', 'name', 12, 'TEXT', 0, 2147483647, null, null,
|
||||
1, -- columnNullable
|
||||
null, null, 12, null, 2147483647, 1, 'YES', null, null, null, null, 'NO', 'NO'
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT null, 'test1', 'name.keyword', 12, 'KEYWORD', 0, null, null, null,
|
||||
SELECT null, 'test1', 'name.keyword', 12, 'KEYWORD', 0, 2147483647, null, null,
|
||||
1, -- columnNullable
|
||||
null, null, 12, null, 2147483647, 1, 'YES', null, null, null, null, 'NO', 'NO'
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT null, 'test2', 'date', 93, 'DATE', 20, null, null, null,
|
||||
SELECT null, 'test2', 'date', 93, 'DATE', 20, 8, null, null,
|
||||
1, -- columnNullable
|
||||
null, null, 93, null, null, 1, 'YES', null, null, null, null, 'NO', 'NO'
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT null, 'test2', 'float', 7, 'FLOAT', 15, null, null, 2,
|
||||
SELECT null, 'test2', 'float', 7, 'FLOAT', 15, 4, null, 2,
|
||||
1, -- columnNullable
|
||||
null, null, 7, null, null, 2, 'YES', null, null, null, null, 'NO', 'NO'
|
||||
FROM DUAL
|
||||
UNION ALL
|
||||
SELECT null, 'test2', 'number', -5, 'LONG', 20, null, null, 10,
|
||||
SELECT null, 'test2', 'number', -5, 'LONG', 20, 8, null, 10,
|
||||
1, -- columnNullable
|
||||
null, null, -5, null, null, 3, 'YES', null, null, null, null, 'NO', 'NO'
|
||||
FROM DUAL
|
||||
|
|
Loading…
Reference in New Issue