Skip to content

Support trendline command in Calcite#3741

Merged
LantaoJin merged 8 commits intoopensearch-project:mainfrom
songkant-aws:trendline-command
Jun 10, 2025
Merged

Support trendline command in Calcite#3741
LantaoJin merged 8 commits intoopensearch-project:mainfrom
songkant-aws:trendline-command

Conversation

@songkant-aws
Copy link
Copy Markdown
Collaborator

@songkant-aws songkant-aws commented Jun 5, 2025

Description

Support trendline command in Calcite

Related Issues

Resolves #3466

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: Songkan Tang <songkant@amazon.com>
@LantaoJin
Copy link
Copy Markdown
Member

CI failures CalcitePPLAppendcolTest > ... FAILED is not related to this fixing.

@LantaoJin LantaoJin added calcite calcite migration releated PPL Piped processing language labels Jun 5, 2025
Copy link
Copy Markdown
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

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

Will wma work in v2? Please add wma related documents in trendline.rst


Limitation
==========
The ``trendline`` command will filter out all NULL values to make sure result correctness because it's meaningless to count NULL values. But this may reduce lines in result for further processing. No newline at end of file
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.

Change to:
Starting with version 3.1.0, the trendline command requires all values in the specified field to be non-null. Any null values present in the calculation field will be automatically excluded from the command's output.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done


trendlineType
: SMA
| WMA
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.

update doc to explain new algorithm?

…lcite

Signed-off-by: Songkan Tang <songkant@amazon.com>
@songkant-aws
Copy link
Copy Markdown
Collaborator Author

@LantaoJin @penghuo Updated the doc with new wma algorithm and callout it's supported with Calcite enabled.

dai-chen
dai-chen previously approved these changes Jun 6, 2025
Syntax
============
`TRENDLINE [sort <[+|-] sort-field>] SMA(number-of-datapoints, field) [AS alias] [SMA(number-of-datapoints, field) [AS alias]]...`
`TRENDLINE [sort <[+|-] sort-field>] [SMA|WMA](number-of-datapoints, field) [AS alias] [[SMA|WMA](number-of-datapoints, field) [AS alias]]...`
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.

Should this command later enforce sorting either on an implicit timestamp field?

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.

Should this command later enforce sorting either on an implicit timestamp field?

We could wait for more user feedbacks. Seems more than one command could be affected with an implicit timestamp field.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it could depend on customer feature request.

LantaoJin
LantaoJin previously approved these changes Jun 7, 2025
Copy link
Copy Markdown
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

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

LGTM once typo is fixed.

Signed-off-by: Songkan Tang <songkant@amazon.com>
@songkant-aws songkant-aws dismissed stale reviews from LantaoJin and dai-chen via 4c178e7 June 9, 2025 02:52
@songkant-aws
Copy link
Copy Markdown
Collaborator Author

@LantaoJin @dai-chen Fixed typo and make some doc phrasing clearer.

import org.json.JSONObject;
import org.junit.jupiter.api.Test;

public class CalcitePPLTrendlineIT extends CalcitePPLIntegTestCase {
Copy link
Copy Markdown
Member

@LantaoJin LantaoJin Jun 9, 2025

Choose a reason for hiding this comment

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

missing CalcitePPLTrendlinePushdownIT if we add IT in standalone

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's added now.

Signed-off-by: Songkan Tang <songkant@amazon.com>
LantaoJin
LantaoJin previously approved these changes Jun 9, 2025
Copy link
Copy Markdown
Member

@LantaoJin LantaoJin left a comment

Choose a reason for hiding this comment

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

LGTM, waiting CI pass

Signed-off-by: Songkan Tang <songkant@amazon.com>
@LantaoJin LantaoJin merged commit 313dc0f into opensearch-project:main Jun 10, 2025
22 checks passed
penghuo pushed a commit that referenced this pull request Jun 16, 2025
* Support trendline command in Calcite

Signed-off-by: Songkan Tang <songkant@amazon.com>

* Fix CalciteExplainIT for trendline command

Signed-off-by: Songkan Tang <songkant@amazon.com>

* Update trendline.rst doc to callout new wma algorithm supported by Calcite

Signed-off-by: Songkan Tang <songkant@amazon.com>

* Fix typo in the doctest and rephrase the doc and formula

Signed-off-by: Songkan Tang <songkant@amazon.com>

* Add missing trendline pushdown IT

Signed-off-by: Songkan Tang <songkant@amazon.com>

* Remove unexpected change

Signed-off-by: Songkan Tang <songkant@amazon.com>

---------

Signed-off-by: Songkan Tang <songkant@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
@songkant-aws songkant-aws deleted the trendline-command branch July 22, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

calcite calcite migration releated PPL Piped processing language

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Support Trendline command with Calcite

4 participants