@@ -48,7 +48,27 @@ Result<ArrowArray> BucketTransform::Transform(const ArrowArray& input) {
4848}
4949
5050Result<std::shared_ptr<Type>> BucketTransform::ResultType () const {
51- return NotImplemented (" BucketTransform::result_type" );
51+ auto src_type = source_type ();
52+ if (!src_type) {
53+ return NotSupported (" null is not a valid input type for bucket transform" );
54+ }
55+ switch (src_type->type_id ()) {
56+ case TypeId::kInt :
57+ case TypeId::kLong :
58+ case TypeId::kDecimal :
59+ case TypeId::kDate :
60+ case TypeId::kTime :
61+ case TypeId::kTimestamp :
62+ case TypeId::kTimestampTz :
63+ case TypeId::kString :
64+ case TypeId::kUuid :
65+ case TypeId::kFixed :
66+ case TypeId::kBinary :
67+ return std::make_shared<IntType>();
68+ default :
69+ return NotSupported (" {} is not a valid input type for bucket transform" ,
70+ src_type->ToString ());
71+ }
5272}
5373
5474TruncateTransform::TruncateTransform (std::shared_ptr<Type> const & source_type,
@@ -60,7 +80,21 @@ Result<ArrowArray> TruncateTransform::Transform(const ArrowArray& input) {
6080}
6181
6282Result<std::shared_ptr<Type>> TruncateTransform::ResultType () const {
63- return NotImplemented (" TruncateTransform::result_type" );
83+ auto src_type = source_type ();
84+ if (!src_type) {
85+ return NotSupported (" null is not a valid input type for truncate transform" );
86+ }
87+ switch (src_type->type_id ()) {
88+ case TypeId::kInt :
89+ case TypeId::kLong :
90+ case TypeId::kDecimal :
91+ case TypeId::kString :
92+ case TypeId::kBinary :
93+ return src_type;
94+ default :
95+ return NotSupported (" {} is not a valid input type for truncate transform" ,
96+ src_type->ToString ());
97+ }
6498}
6599
66100YearTransform::YearTransform (std::shared_ptr<Type> const & source_type)
@@ -71,7 +105,19 @@ Result<ArrowArray> YearTransform::Transform(const ArrowArray& input) {
71105}
72106
73107Result<std::shared_ptr<Type>> YearTransform::ResultType () const {
74- return NotImplemented (" YearTransform::result_type" );
108+ auto src_type = source_type ();
109+ if (!src_type) {
110+ return NotSupported (" null is not a valid input type for year transform" );
111+ }
112+ switch (src_type->type_id ()) {
113+ case TypeId::kDate :
114+ case TypeId::kTimestamp :
115+ case TypeId::kTimestampTz :
116+ return std::make_shared<IntType>();
117+ default :
118+ return NotSupported (" {} is not a valid input type for year transform" ,
119+ src_type->ToString ());
120+ }
75121}
76122
77123MonthTransform::MonthTransform (std::shared_ptr<Type> const & source_type)
@@ -82,7 +128,19 @@ Result<ArrowArray> MonthTransform::Transform(const ArrowArray& input) {
82128}
83129
84130Result<std::shared_ptr<Type>> MonthTransform::ResultType () const {
85- return NotImplemented (" MonthTransform::result_type" );
131+ auto src_type = source_type ();
132+ if (!src_type) {
133+ return NotSupported (" null is not a valid input type for month transform" );
134+ }
135+ switch (src_type->type_id ()) {
136+ case TypeId::kDate :
137+ case TypeId::kTimestamp :
138+ case TypeId::kTimestampTz :
139+ return std::make_shared<IntType>();
140+ default :
141+ return NotSupported (" {} is not a valid input type for month transform" ,
142+ src_type->ToString ());
143+ }
86144}
87145
88146DayTransform::DayTransform (std::shared_ptr<Type> const & source_type)
@@ -93,7 +151,19 @@ Result<ArrowArray> DayTransform::Transform(const ArrowArray& input) {
93151}
94152
95153Result<std::shared_ptr<Type>> DayTransform::ResultType () const {
96- return NotImplemented (" DayTransform::result_type" );
154+ auto src_type = source_type ();
155+ if (!src_type) {
156+ return NotSupported (" null is not a valid input type for day transform" );
157+ }
158+ switch (src_type->type_id ()) {
159+ case TypeId::kDate :
160+ case TypeId::kTimestamp :
161+ case TypeId::kTimestampTz :
162+ return std::make_shared<DateType>();
163+ default :
164+ return NotSupported (" {} is not a valid input type for day transform" ,
165+ src_type->ToString ());
166+ }
97167}
98168
99169HourTransform::HourTransform (std::shared_ptr<Type> const & source_type)
@@ -104,7 +174,18 @@ Result<ArrowArray> HourTransform::Transform(const ArrowArray& input) {
104174}
105175
106176Result<std::shared_ptr<Type>> HourTransform::ResultType () const {
107- return NotImplemented (" HourTransform::result_type" );
177+ auto src_type = source_type ();
178+ if (!src_type) {
179+ return NotSupported (" null is not a valid input type for hour transform" );
180+ }
181+ switch (src_type->type_id ()) {
182+ case TypeId::kTimestamp :
183+ case TypeId::kTimestampTz :
184+ return std::make_shared<IntType>();
185+ default :
186+ return NotSupported (" {} is not a valid input type for hour transform" ,
187+ src_type->ToString ());
188+ }
108189}
109190
110191VoidTransform::VoidTransform (std::shared_ptr<Type> const & source_type)
@@ -115,7 +196,11 @@ Result<ArrowArray> VoidTransform::Transform(const ArrowArray& input) {
115196}
116197
117198Result<std::shared_ptr<Type>> VoidTransform::ResultType () const {
118- return NotImplemented (" VoidTransform::result_type" );
199+ auto src_type = source_type ();
200+ if (!src_type) {
201+ return NotSupported (" null is not a valid input type for void transform" );
202+ }
203+ return src_type;
119204}
120205
121206} // namespace iceberg
0 commit comments