GoogleCloudPlatform / GoogleCloudPlatform/professional-services-data-validator
Review code in Oracle strftime
- Dominant language
- Python
- Stars
- 524
- Forks
- 171
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 4
Description
The code below from Oracle `_reduce_tokens()` appears to be incorrect. `%e` is to format day of the month padded with a leading space.
```
elif token == "%e":
# pad with spaces instead of zeros
value = sa.func.replace(sa.func.to_char(arg, "DD"), "0", " ")
```
The Oracle code was introduced during the upgrade to ibis 5.1.0. The developer wanted to replace occurrences of '05', '06' in month number as ' 5' and ' 6'. It is not clear if string needs to have a space. If not, the developer could use the format specified 'FMDD' which will not produce '05' and '06', instead '5' and '6'. As the code is currently written, it would appear that day `10` will appear as `1 ` and likely show as not matching. This needs to be verified and if true an issue needs to be opened.
I suspect it's never mattered because DVT doesn't use the `%e` format. Still - we should look into it.
The same concern can be found in Db2 `_reduce_tokens()`.
Contributor guide
Research direction
Inspect the Oracle and Db2 `_reduce_tokens()` implementations, focusing on the `%e` branches and how `to_char` and `replace` handle days 05, 06, and 10. Reproduce the formatting behavior and check any existing dialect tests; done means confirming whether the output matches `%e` semantics and documenting or correcting the issue in both implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100