goccy / bigquery-emulator

BigQuery emulator server implemented in Go
MIT License
840 stars 107 forks source link

Date_Diff function returning incorrect values #359

Closed bradycale-taulia closed 1 month ago

bradycale-taulia commented 1 month ago

What happened?

When using the Date_Diff function in the emulator, it is returning incorrect results.

As an example, running this sql against a single row:

SELECT ic.invoice_id AS debug_date_diff_8, ic.funding_request_date AS debug_date_diff_7, ic.ep_taken_enh_maturity_date AS debug_date_diff_6, DATE_DIFF(ic.ep_taken_enh_maturity_date, ic.funding_request_date, day) AS debug_date_diff_5 FROM invoice_core ic

Returns the following values:

{"debug_date_diff_8":"9dcbc462da4c4e6e96c034fe30f4db96","debug_date_diff_7":"2024-09-30","debug_date_diff_6":"2024-10-05","debug_date_diff_5":-25}

The value of -25 for the Date_Diff function is not correct. If we run this statement against the GCP Bigquery instance we get a value of 5 for the Date_Diff.

What did you expect to happen?

It should return a value of 5 using the parameters above.

How can we reproduce it (as minimally and precisely as possible)?

Call Date_Diff function

Anything else we need to know?

No response

bradycale-taulia commented 1 month ago

Remove. I was testing against v4.3. It appears this is fixed in v6.5