[Date Conversion] Enables conversion date to int#427
Conversation
This commit enables conversion from date to int. Resolves: #317 Signed-off-by: Dmitrii Makarenko <dmitrii.makarenko@intel.com>
| } | ||
| } else if (expr_->type()->isDate()) { | ||
| if (new_type->isDate() || new_type->isTimestamp()) { | ||
| if (new_type->isNumber() || new_type->isDate() || new_type->isTimestamp()) { |
There was a problem hiding this comment.
isNumber includes decimals and FP types. Is it intentional?
There was a problem hiding this comment.
I took conversion timestamp as an example, it uses 'timestamp' -> 'number, date, timestamp'. Maybe we should create some conversion map?
| auto res = runQuery(std::move(dag)); | ||
| LOG(ERROR) << "res: " << res.toString(); | ||
| LOG(ERROR) << "res: " << toArrow(res)->ToString(); | ||
| compare_res_data(res, std::vector<int32_t>({946684800, 1426636800})); |
There was a problem hiding this comment.
Are these numbers what you would expect for used dates in kDay time unit?
There was a problem hiding this comment.
I converted 2000-01-01, 2015-03-18 to int and used this values. (also checked what happens with online converter https://timestamp.online) In general it can be expanded to Hours and Milli.
There was a problem hiding this comment.
This converter gives you a timestamp in seconds. I would expect different int values when casting dates in different units.
| {"col_dec", ctx().decimal64(10, 2)}, | ||
| {"col_b", ctx().boolean()}, | ||
| {"col_str", ctx().text()}, | ||
| {"col_date", ctx().date32(hdk::ir::TimeUnit::kDay)}, |
There was a problem hiding this comment.
We need to check other date sizes and time units as well.
There was a problem hiding this comment.
Sure, it's initial check.
|
For some reason I can't update pr, so recreating it: #472 |
This commit enables conversion from date to int.
Resolves: #317
Signed-off-by: Dmitrii Makarenko dmitrii.makarenko@intel.com