Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(expr): to_char prints wrong BC years #19944

Open
xiangjinwu opened this issue Dec 26, 2024 · 0 comments
Open

bug(expr): to_char prints wrong BC years #19944

xiangjinwu opened this issue Dec 26, 2024 · 0 comments
Labels
component/func-expr Support a SQL function or operator priority/low type/bug Something isn't working

Comments

@xiangjinwu
Copy link
Contributor

Describe the bug

ISO 8601 year 0 is display in PostgreSQL as 0001 BC instead of 0000. RisingWave fails to consider this in to_char.

Error message/log

dev=> select to_char('0001-01-01'::date - interval '1' second, 'YYYY');
 to_char 
---------
 0000
(1 row)

To Reproduce

select to_char('0001-01-01'::date - interval '1' second, 'YYYY');

Expected behavior

Same as PostgreSQL:

test=# select to_char('0001-01-01'::date - interval '1' second, 'YYYY');
 to_char 
---------
 0001
(1 row)

test=# select to_char('0001-01-01'::date - interval '1' second, 'YYYY BC');
 to_char 
---------
 0001 BC
(1 row)

test=# select to_char('0001-01-01'::date - interval '1' second, 'YYYY AD');
 to_char 
---------
 0001 BC
(1 row)

test=# select to_char('0001-01-01'::date + interval '1' second, 'YYYY BC');
 to_char 
---------
 0001 AD
(1 row)

test=# select to_char('0001-01-01'::date + interval '1' second, 'YYYY AD');
 to_char 
---------
 0001 AD
(1 row)

How did you deploy RisingWave?

No response

The version of RisingWave

No response

Additional context

When using the chrono crate, although we can obtain the correct value with DateLike::year_ce instead of year, there is no corresponding specifier in its strftime module.

#11241 #15053

@xiangjinwu xiangjinwu added type/bug Something isn't working priority/low component/func-expr Support a SQL function or operator labels Dec 26, 2024
@github-actions github-actions bot added this to the release-2.3 milestone Dec 26, 2024
@xiangjinwu xiangjinwu removed this from the release-2.3 milestone Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/func-expr Support a SQL function or operator priority/low type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant