-
Notifications
You must be signed in to change notification settings - Fork 25.8k
SQL: SYS TYPES adjustments for ODBC #30386
Copy link
Copy link
Closed
Labels
Description
Elasticsearch version: master @ 65dbc17
The ODBC driver uses now the results return by SYS TYPES query to answer app's inquiries on column types. The following is a list of proposed changes that would be needed to stay inline with the ODBC spec:
PRECISIONandAUTO_INCREMENTcolumns:
These have been renamed in ODBC 3.x toCOLUMN_SIZE(just like already returned bySYS COLUMNS) andAUTO_UNIQUE_VALUErespectively. The plugin currently returns the JDBC nomenclature. Not positive what we should do here: in ODBC no application should ever look at the column names, because ODBC specifies what should be returned in each column by order, not name. If this is the case also for JDBC, I'd recommend renaming to the ODBC standard.DATEdata type:- This type is currently assigned the value 93 in column
DATA_TYPE. In both ODBC and JDBC specs, this value corresponds to a TIMESTAMP type (SQL_TYPE_TIMESTAMP). Moreover, ES/SQL does return a timestamp representation of it (ISO8601). So I'm not sure what we want to have here, but I believe we should either correct the value to 91 (SQL_TYPE_DATE) or rename the type to 'TIMESTAMP'. - The value for column
PRECISION(/COLUMN_SIZE) for this type should be 20 (not 19). This is because this indicates the “number of characters in the character representation” and len("1953-09-02T00:00:00Z")==20 (interestingly,SYS COLUMNSdoes return value 20 forCOLUMN_SIZEcolumn already). Note: this might need to be adjusted to 24, if SQL: inconsistent date(time) format handling. #30002 is implemented; alternatively, if we choose not to implement that, we need to make sure we always return the date/time representation without the milliseconds component.
- This type is currently assigned the value 93 in column
SQL_DATA_TYPEcolumn:
The values in this column are always 0. The JDBC doesn't make use of this column ("unused"). The ODBC spec mandates that “[t]his column is the same as the DATA_TYPE column, except for interval and datetime data types.”
Now, we don't have interval types, so that's fine. For theDATEdata type, this column should have the value 9 (ODBC'sSQL_DATETIMEvalue) and column SQL_DATETIME_SUB should have either value 3 (ODBC'sSQL_CODE_TIMESTAMPvalue) or 1 (ODBC'sSQL_CODE_DATEvalue), according to the decision for the point above. Codes are concisely explained here and the values lifted from the specs.SQL_DATETIME_SUBcolumn:
This is currentlynull. The JDBC doesn't make use of the column ("unused"). For ODBC, it should be 0 for all types, except for DATE/TIMESTAMP where it should 3 or 1 (as per above).AUTO_INCREMENT(/AUTO_UNIQUE_VALUE) column:
The column is currently alwaysnull. However,SYS COLUMNSreturnsNOin the equivalentIS_AUTOINCREMENTcolumn, instead of a corresponding empty string for the unknown/not_applicable case (asnullindicates). I believe we should synchronise these two columns to return eithernull/"" or preferablyfalse/NO.MINIMUM_SCALEandMAXIMUM_SCALEcolumns:
The values here are alwaysnull, while they should be 0 for the exact numeric types (the ints); also ifDATEis transitioned fully toTIMESTAMP, it's corresponding values should be 0 or 3, depending on how SQL: inconsistent date(time) format handling. #30002 is implemented.PRECISIONcolumn:
For numeric types, this column should contain “the maximum number of digits used by the data type”. The values currently returned match the ODBC spec for all the integral types and for theFLOATdata type (7). ForDOUBLE, it is 1 higher (16 returned vs 15 in the spec) andHALF_andSCALED_FLOAThave no direct equivalent since their data type (6) is reserved for variable precision floats. So I just wanted to make sure that the non-aligned values are accurate (which is possible).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.