Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions presto-docs/src/main/sphinx/connector/hive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ connector supports this by allowing the same conversions as Hive:
* ``real`` to ``double``
* Widening conversions for integers, such as ``tinyint`` to ``smallint``

In adition to the conversions above, the Hive connector does also support the following conversions when working with Parquet file format:

* ``integer`` to ``bigint``, ``real`` and ``double``
* ``bigint`` to ``real`` and ``double``

Any conversion failure will result in null, which is the same behavior
as Hive. For example, converting the string ``'foo'`` to a number,
or converting the string ``'1234'`` to a ``tinyint`` (which has a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,14 @@ public static boolean checkSchemaMatch(org.apache.parquet.schema.Type parquetTyp
PrimitiveTypeName parquetTypeName = parquetType.asPrimitiveType().getPrimitiveTypeName();
switch (parquetTypeName) {
case INT64:
return prestoType.equals(BIGINT) || prestoType.equals(DECIMAL) || prestoType.equals(TIMESTAMP);
return prestoType.equals(BIGINT) || prestoType.equals(DECIMAL) || prestoType.equals(TIMESTAMP) || prestoType.equals(StandardTypes.REAL) || prestoType.equals(StandardTypes.DOUBLE);
case INT32:
return prestoType.equals(INTEGER) || prestoType.equals(BIGINT) || prestoType.equals(SMALLINT) || prestoType.equals(DATE) || prestoType.equals(DECIMAL) || prestoType.equals(TINYINT);
return prestoType.equals(INTEGER) || prestoType.equals(BIGINT) || prestoType.equals(SMALLINT) || prestoType.equals(DATE) || prestoType.equals(DECIMAL) ||
prestoType.equals(TINYINT) || prestoType.equals(REAL) || prestoType.equals(StandardTypes.DOUBLE);
case BOOLEAN:
return prestoType.equals(StandardTypes.BOOLEAN);
case FLOAT:
return prestoType.equals(REAL);
return prestoType.equals(REAL) || prestoType.equals(StandardTypes.DOUBLE);
case DOUBLE:
return prestoType.equals(StandardTypes.DOUBLE);
case BINARY:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ public void testSchemaMismatch()
"test", arrayBlockOf(RowType.anonymous(ImmutableList.of(INTEGER)), rowBlockOf(ImmutableList.of(INTEGER), 1L))));

HiveErrorCode expectedErrorCode = HIVE_PARTITION_SCHEMA_MISMATCH;
String expectedMessageFloatDouble = "The column column_name of table schema.table is declared as type double, but the Parquet file ((.*?)) declares the column as type FLOAT";

// Make sure INT64 is still readable as Timestamp see https://github.com/prestodb/presto/issues/13855
assertThatFileFormat(PARQUET)
Expand All @@ -685,7 +684,7 @@ public void testSchemaMismatch()
.withWriteColumns(ImmutableList.of(floatColumn))
.withReadColumns(ImmutableList.of(doubleColumn))
.withSession(parquetPageSourceSession)
.isFailingForPageSource(new ParquetPageSourceFactory(FUNCTION_AND_TYPE_MANAGER, FUNCTION_RESOLUTION, HDFS_ENVIRONMENT, STATS, METADATA_READER), expectedErrorCode, expectedMessageFloatDouble);
.isReadableByPageSource(new ParquetPageSourceFactory(FUNCTION_AND_TYPE_MANAGER, FUNCTION_RESOLUTION, HDFS_ENVIRONMENT, STATS, METADATA_READER));

String expectedMessageDoubleLong = "The column column_name of table schema.table is declared as type bigint, but the Parquet file ((.*?)) declares the column as type DOUBLE";

Expand Down
Loading