zclllyybb commented on issue #3883:
URL: https://github.com/apache/doris-website/issues/3883#issuecomment-4601434847
Breakwater-GitHub-Analysis-Slot: slot_fdfc1ed06e14
Initial analysis from current upstream Doris master (`7ec8f7d0d61`):
This looks like an expected display/metadata compatibility behavior, not a
loss of the actual column type.
The relevant code paths are different:
- Parser/type mapping: `text` and `string` are both mapped to the same Doris
string type. In `DataType.convertPrimitiveFromStrings(...)`, both `text` and
`string` return `StringType.INSTANCE`; `StringType.toCatalogDataType()` returns
`Type.STRING`.
- SQL display for table DDL: `ScalarType.toSql()` and
`ScalarType.toString()` render `PrimitiveType.STRING` as `text`. `SHOW CREATE
TABLE` goes through `Env.getDdlStmt(...)` -> `Column.toSql(...)` ->
`type.toSql()`, so it prints `text`.
- `DESC` / unfiltered `SHOW COLUMNS`: `ShowColumnsCommand` reads the column
type from the catalog type display path, so it also prints `text`.
- `information_schema.columns`: this is populated by the BE schema scanner.
`schema_columns_scanner.cpp` explicitly says `DATA_TYPE` is converted for MySQL
compatibility, and maps both `TPrimitiveType::VARCHAR` and
`TPrimitiveType::STRING` to `varchar`. In the same scanner, `COLUMN_TYPE` for
`TPrimitiveType::STRING` returns `string`.
So on current master I would expect:
- DDL input `STRING` and `TEXT` are accepted as the same Doris
variable-length string type.
- `SHOW CREATE TABLE` and `DESC` display that type as `text`.
- `information_schema.columns.DATA_TYPE` displays `varchar` for
MySQL-compatible metadata.
- `information_schema.columns.COLUMN_TYPE` should display `string` for this
type. If `COLUMN_TYPE` is also `varchar` in the reporter's environment, that
would need a version-specific check because it does not match the current
master code path.
Recommended next step for this website issue: treat it as a documentation
gap. The `STRING` data type page currently describes length and usage
restrictions, but it does not explain the display aliases. A useful doc note
would be:
> `STRING` and `TEXT` are accepted spellings for the same Doris
variable-length string type. Doris may canonicalize this type as `TEXT` in
`SHOW CREATE TABLE` and `DESC`. In `information_schema.columns`, `DATA_TYPE`
follows MySQL-compatible metadata and may show `varchar`; use `COLUMN_TYPE`
when checking the Doris-specific column type.
Missing information only if we want to validate a version-specific
inconsistency:
- Doris version/build.
- Minimal `CREATE TABLE` statement.
- Exact selected output for `DATA_TYPE` and `COLUMN_TYPE`, for example:
`select column_name, data_type, column_type from
information_schema.columns where table_name = '...';`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]