Skip to content

Commit 638a1f6

Browse files
rui-mozhouyuan
authored andcommitted
Allow reading integers into smaller-range types
1 parent 76375db commit 638a1f6

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

velox/dwio/parquet/reader/ParquetReader.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,8 @@ TypePtr ReaderBase::convertType(
793793
requestedType,
794794
isRepeated,
795795
[](const TypePtr& type) {
796-
return type->kind() == TypeKind::SMALLINT ||
796+
return type->kind() == TypeKind::TINYINT ||
797+
type->kind() == TypeKind::SMALLINT ||
797798
type->kind() == TypeKind::INTEGER ||
798799
type->kind() == TypeKind::BIGINT;
799800
}),
@@ -815,7 +816,9 @@ TypePtr ReaderBase::convertType(
815816
requestedType,
816817
isRepeated,
817818
[](const TypePtr& type) {
818-
return type->kind() == TypeKind::INTEGER ||
819+
return type->kind() == TypeKind::TINYINT ||
820+
type->kind() == TypeKind::SMALLINT ||
821+
type->kind() == TypeKind::INTEGER ||
819822
type->kind() == TypeKind::BIGINT;
820823
}),
821824
kTypeMappingErrorFmtStr,
@@ -835,8 +838,12 @@ TypePtr ReaderBase::convertType(
835838
isCompatible(
836839
requestedType,
837840
isRepeated,
838-
[](const TypePtr& type) {
839-
return type->kind() == TypeKind::BIGINT;
841+
[](const TypePtr& type, const TypePtr& requestedType) {
842+
return type->kind() == TypeKind::TINYINT ||
843+
type->kind() == TypeKind::SMALLINT ||
844+
type->kind() == TypeKind::INTEGER ||
845+
type->kind() == TypeKind::BIGINT ||
846+
requestedType->isDecimal();
840847
}),
841848
kTypeMappingErrorFmtStr,
842849
"BIGINT",
@@ -1007,7 +1014,9 @@ TypePtr ReaderBase::convertType(
10071014
requestedType,
10081015
isRepeated,
10091016
[](const TypePtr& type) {
1010-
return type->kind() == TypeKind::INTEGER ||
1017+
return type->kind() == TypeKind::TINYINT ||
1018+
type->kind() == TypeKind::SMALLINT ||
1019+
type->kind() == TypeKind::INTEGER ||
10111020
type->kind() == TypeKind::BIGINT;
10121021
}),
10131022
kTypeMappingErrorFmtStr,
@@ -1037,7 +1046,10 @@ TypePtr ReaderBase::convertType(
10371046
requestedType,
10381047
isRepeated,
10391048
[](const TypePtr& type) {
1040-
return type->kind() == TypeKind::BIGINT;
1049+
return type->kind() == TypeKind::TINYINT ||
1050+
type->kind() == TypeKind::SMALLINT ||
1051+
type->kind() == TypeKind::INTEGER ||
1052+
type->kind() == TypeKind::BIGINT;
10411053
}),
10421054
kTypeMappingErrorFmtStr,
10431055
"BIGINT",

0 commit comments

Comments
 (0)