[fix](function) error scale set in unix_timestamp (#36110) (#37619)

## Proposed changes

```
mysql [test]>set DEBUG_SKIP_FOLD_CONSTANT = true;
Query OK, 0 rows affected (0.00 sec)

mysql [test]>select cast(unix_timestamp("2024-01-01",'yyyy-MM-dd') as bigint);
+------------------------------------------------------------+
| cast(unix_timestamp('2024-01-01', 'yyyy-MM-dd') as BIGINT) |
+------------------------------------------------------------+
|                                           1704038400000000 |
+------------------------------------------------------------+
```
now
```
mysql [test]>select cast(unix_timestamp("2024-01-01",'yyyy-MM-dd') as bigint);
+------------------------------------------------------------+
| cast(unix_timestamp('2024-01-01', 'yyyy-MM-dd') as BIGINT) |
+------------------------------------------------------------+
|                                                 1704038400 |
+------------------------------------------------------------+
1 row in set (0.01 sec)
```

The column does not have a scale set, but the cast uses the scale to
perform the cast.


<!--Describe your changes.-->

## Proposed changes

Issue Number: close #xxx

<!--Describe your changes.-->
This commit is contained in:
Mryange
2024-07-15 10:00:04 +08:00
committed by GitHub
parent b55dd6f644
commit 8de13c5cc8
3 changed files with 6 additions and 1 deletions

View File

@ -831,7 +831,7 @@ struct UnixTimeStampStrImpl {
std::tie(col_right, format_const) =
unpack_if_const(block.get_by_position(arguments[1]).column);
auto col_result = ColumnDecimal<Decimal64>::create(input_rows_count, 0);
auto col_result = ColumnDecimal<Decimal64>::create(input_rows_count, 6);
auto null_map = ColumnVector<UInt8>::create(input_rows_count);
auto& col_result_data = col_result->get_data();
auto& null_map_data = null_map->get_data();