From ee8682c83b156969889ce749047d75eb934a2502 Mon Sep 17 00:00:00 2001 From: Joe Johnson Date: Tue, 24 Oct 2023 11:45:40 -0400 Subject: [PATCH] Expand docs for Hive schema evolution type conversions --- docs/src/main/sphinx/connector/hive.md | 43 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/docs/src/main/sphinx/connector/hive.md b/docs/src/main/sphinx/connector/hive.md index ceb15abafbdc..093a9c19cbb6 100644 --- a/docs/src/main/sphinx/connector/hive.md +++ b/docs/src/main/sphinx/connector/hive.md @@ -628,14 +628,41 @@ Hive directly, most operations can be performed using Trino. #### Schema evolution -Hive allows the partitions in a table to have a different schema than the -table. This occurs when the column types of a table are changed after -partitions already exist (that use the original column types). The Hive -connector supports this by allowing the same conversions as Hive: - -- `VARCHAR` to and from `TINYINT`, `SMALLINT`, `INTEGER` and `BIGINT` -- `REAL` to `DOUBLE` -- Widening conversions for integers, such as `TINYINT` to `SMALLINT` +Hive table partitions can differ from the current table schema. This occurs when +the data types of columns of a table are changed from the data types of columns +of preexisting partitions. The Hive connector supports this schema evolution by +allowing the same conversions as Hive. The following table lists possible data +type conversions. + +:::{list-table} Hive schema evolution type conversion +:widths: 25, 75 +:header-rows: 1 + +* - Data type + - Converted to +* - `VARCHAR` + - `TINYINT`, `SMALLINT`, `INTEGER`, `BIGINT`, `TIMESTAMP`, `DATE`, as well as + narrowing conversions for `VARCHAR` +* - `CHAR` + - narrowing conversions for `CHAR` +* - `TINYINT` + - `VARCHAR`, `SMALLINT`, `INTEGER`, `BIGINT` +* - `SMALLINT` + - `VARCHAR`, `INTEGER`, `BIGINT` +* - `INTEGER` + - `VARCHAR`, `BIGINT` +* - `BIGINT` + - `VARCHAR` +* - `REAL` + - `DOUBLE`, `DECIMAL` +* - `DOUBLE` + - `FLOAT`, `DECIMAL` +* - `DECIMAL` + - `DOUBLE`, `REAL`, `VARCHAR`, `TINYINT`, `SMALLINT`, `INTEGER`, `BIGINT`, as + well as narrowing and widening conversions for `DECIMAL` +* - `TIMESTAMP` + - `VARCHAR` +::: Any conversion failure results in null, which is the same behavior as Hive. For example, converting the string `'foo'` to a number,