opensearch-project / opensearch-project/sql

[FEATURE] Support identifiers starting with a digit

Open
#3,964 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking enhancement PPL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

Is your feature request related to a problem?

###
POST {{baseUrl}}/test-script-index/_bulk
Content-Type: application/x-ndjson

{ "index": { "_id": 1 } }
{ "value": 10 }
{ "index": { "_id": 2 } }
{ "value": 20 }
{ "index": { "_id": 3 } }
{ "value": 30 }
{ "index": { "_id": 4 } }
{ "value": 40 }

### FAILED
POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson

{
  "query": "source=test-script-index | stats count() by span(value, 1) as 1v"
}

{
  "error": {
    "reason": "Invalid Query",
    "details": "[1] is not a valid term at this part of the query: '...y span(value, 1) as 1' <-- HERE. Expecting tokens: 'BY'",
    "type": "SyntaxCheckException"
  },
  "status": 400
}

### FAILED
POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson

{
  "query": "source=test-script-index | eval 2xx=value+1"
}

What solution would you like?
We expected PPL support identifiers starting with a digit
Backtick is workaround

###
POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson

{
  "query": "source=test-script-index | stats count() by span(value, 1) as `1v`"
}

What alternatives have you considered?
n/a

Do you have any additional context?
n/a

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two failing PPL requests at /_plugins/_ppl/ and compare them with the backtick workaround. Trace how PPL parses the alias in stats ... as 1v and the assignment in eval 2xx=value+1; the work is done when both forms accept identifiers starting with a digit.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.