Skip to content

Support multiply without blanks - #3830

Closed
qianheng-aws wants to merge 4 commits into
opensearch-project:mainfrom
qianheng-aws:fix720
Closed

qianheng-aws wants to merge 4 commits into
opensearch-project:mainfrom
qianheng-aws:fix720

Conversation

@qianheng-aws

@qianheng-aws qianheng-aws commented Jun 30, 2025 •

Copy link
Copy Markdown
Collaborator

Description

Support multiply without blanks.

Implements it by making ID not allow containing *.

But since we should support index patterns which contains *, we have to make compromise that wrapping it with backticks. However, for the most common case where the index pattern ends with *, it doesn't need wrapping with backticks as we add this specific pattern in the tableIdent.

For example:

source=index* | eval  a = b*10

Or

source=`*index*2020*` | eval a = b*10

Related Issues

Resolves #720

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: Heng Qian <[email protected]>
@qianheng-aws
qianheng-aws marked this pull request as ready for review July 9, 2025 11:53
Comment on lines +1102 to +1103
// specially allow index name ends with * without wrapping it with backticks
: (CLUSTER)? (ident | ID STAR)

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.

I am not sure the table-ident-end-with-star is the only one table-ident-with-star pattern we can ignore backticks.
In another word, this makes a breaking change that blocks the use case of

source=table*.2025*

@qianheng-aws qianheng-aws Jul 10, 2025 •

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.

This PR will no doubt introduce breaking change.

I just want to mitigate the gap for the most common case where only the table idents end ends with star. If we think cluster ident ends with * is also widely used, I may need to find a way to support this case without backticks as well.

@qianheng-aws qianheng-aws Jul 10, 2025 •

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.

If the breaking change for the case where star in the middle of table ident is also unacceptable, the current approach won't make it. Then we need to find another way.

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.

We should support source=table*.2025*.
And we should differenate

  1. wildcard-field vs field. currently, PPL do not support wildcard-field, but it is needed https://github.com/opensearch-project/sql/pull/3830/files
  2. wildcard-string, e.g. source=table*.2025*

@qianheng-aws qianheng-aws Jul 18, 2025 •

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.

  1. Do we have plan to support wildcard-field in the future? It's also supported by current g4 with adding backticks
  2. It can work around by adding backticks
source=`table*.2025*`

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.

It can work around by adding backticks

I don't think the current implementation is a optimal fixing to merge, actually the current issue also contains a workaround a = b * 10. The patching doesn't make thing better IMO.

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.

Find a way to support source=table*.2025*, without adding backticks. It will eliminate the breaking change with the latest code. @LantaoJin @penghuo

@LantaoJin LantaoJin Jul 21, 2025 •

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.

wildcard-field vs field. currently, PPL do not support wildcard-field, but it is needed

Seems the * can be used in field name in OpenSearch:

PUT test002
{
  "mappings": {
    "properties": {
      "gender": {
        "type": "text",
        "fielddata": true
      },
      "updated_at": {
        "type": "date",
        "format": "strict_date_time"
      },
      "*id": {
        "type": "integer"
      }
    }
  }
}

POST test002/_bulk
{"create": {}}
{"gender":"M","updated_at":"2013-07-15T10:41:34Z", "*id": 1}
{"create": {}}
{"gender":"M","updated_at":"2013-07-15T10:42:34Z", "*id": 1}
{"create": {}}
{"gender":"F","updated_at":"2013-07-15T10:43:34Z", "*id": 1}
{"create": {}}
{"gender":"F","updated_at":"2013-07-15T10:44:34Z", "*id": 1}

POST /_plugins/_ppl/
{
  "query": """
  source = test002 | eval `10 * *id` = 10 * *id | fields `10 * *id`
  """
}

{
  "schema": [
    {
      "name": "10 * *id",
      "type": "int"
    }
  ],
  "datarows": [
    [
      10
    ],
    [
      10
    ],
    [
      10
    ],
    [
      10
    ]
  ],
  "total": 4,
  "size": 4
}

I think we should just call out in doc that the blanks are required for multiply operator in PPL/SQL syntax.

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.

Since we need to support wildcard-field as well, it's not easy to fix this issue without introducing breaking change.

Will close this PR

Signed-off-by: Heng Qian <[email protected]>
ppl:
body:
query: 'source=test* | eval a = balance*10 | fields a'
query: 'source= *te*st* | eval a = balance*10 | fields a'

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.

why add a SPACE after =? can it be source=*te*st*?

@LantaoJin LantaoJin Jul 21, 2025 •

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 add a case:

source=*te*st* | eval a = balance*10 | fields a
source=`*te*st*` | eval a = balance *10 | fields a
source=*te*st*:`*te*st*` | eval a = balance* 10 | fields a

@qianheng-aws

qianheng-aws commented Jul 21, 2025 •

Copy link
Copy Markdown
Collaborator Author

wildcard-field vs field. currently, PPL do not support wildcard-field, but it is needed

Since we need to support wildcard-field as well, it's not easy to fix this issue without introducing breaking change.

Will close this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Expressions in PPL require whitespace around * characters

3 participants