Skip to content

fix timestamp bug#3542

Merged
qianheng-aws merged 3 commits into
opensearch-project:mainfrom
xinyual:fixTimestampBug
Apr 17, 2025
Merged

fix timestamp bug#3542
qianheng-aws merged 3 commits into
opensearch-project:mainfrom
xinyual:fixTimestampBug

Conversation

@xinyual
Copy link
Copy Markdown
Contributor

@xinyual xinyual commented Apr 14, 2025

Description

This pr fix the timestamp bug when take time argument. It uses the current function properties. We now follow the same logic as

* All types are converted to TIMESTAMP actually before the function call - it is responsibility
to firstly transfer it to timestamp.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]
#3545

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: xinyual <xinyual@amazon.com>

@Test
public void testTimestampWithTimeInput() {
String utcTomorrow = LocalDate.now().plusDays(1).toString();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be an edge case this test should be flakey when it was ran at the time point crossing a day.

I think it should use a fixed time via Hook.CURRENT_TIMESTAMP once changing to use the time properties in Calcite.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we don't use the latest refactor framework so Hook wouldn't work. But after changing it, I will use Hook in this IT.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a TODO here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp(time('12:00:00'), time('12:00:00'))

what is meaning of time+time? should we limit the first argument be date only?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In v2, we will implicitly convert the time into timestamp. The logic of v2 timestamp is transfer two arguments into timestamp (if we have two.), then extract time part from the second timestamp and then add it to the first timestamp.

qianheng-aws
qianheng-aws previously approved these changes Apr 14, 2025
@qianheng-aws
Copy link
Copy Markdown
Collaborator

CI failed for java21, is this a known failure?

@qianheng-aws
Copy link
Copy Markdown
Collaborator

CI failed for java21, is this a known failure?

Should be addressed by this fix: #3543

Signed-off-by: xinyual <xinyual@amazon.com>
@LantaoJin
Copy link
Copy Markdown
Member

Could you open an issue?

@LantaoJin LantaoJin added the calcite calcite migration releated label Apr 14, 2025
* We need to write our own since we are actually implement timestamp add here
* (STRING/DATE/TIME/DATETIME/TIMESTAMP) -> TIMESTAMP (STRING/DATE/TIME/DATETIME/TIMESTAMP,
* STRING/DATE/TIME/DATETIME/TIMESTAMP) -> TIMESTAMP
* STRING/DATE/TIME/DATETIME/TIMESTAMP) -> TIMESTAMP It's implicitly transferred into timestamp, so
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format this java doc for more readable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: xinyual <xinyual@amazon.com>
@xinyual
Copy link
Copy Markdown
Contributor Author

xinyual commented Apr 15, 2025

Could you open an issue?

Done. #3545

@LantaoJin LantaoJin requested a review from qianheng-aws April 16, 2025 09:30
@qianheng-aws qianheng-aws merged commit eb718fc into opensearch-project:main Apr 17, 2025
22 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* fix timestamp bug

Signed-off-by: xinyual <xinyual@amazon.com>

* add TODO

Signed-off-by: xinyual <xinyual@amazon.com>

* change doc

Signed-off-by: xinyual <xinyual@amazon.com>

---------

Signed-off-by: xinyual <xinyual@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calcite calcite migration releated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants