opensearch-project / opensearch-project/sql

[BUG] Query with UNION operator fails with NullPointerException

Open
#2,540 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug error-experience SQL
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

What is the bug?
Present in OpenSearch 2.12.0, 2.11.0, 1.3.10
The documentation states that Union queries are supported. However, when attempting a simple union query, the request fails with:

{ "error": { "reason": "There was internal problem at backend", "details": "", "type": "NullPointerException" }, "status": 500 }

The query returns the expected result when ?format=csv is added to the request URL.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Index data into OpenSearch (for this example, I am using simple novels/song data)
  2. perform query involving union:
    { "query": "SELECT title FROM novels UNION SELECT title FROM songs" }
  3. NullPointerException error returned

What is the expected behavior?
Union operator to work as expected. In above example adding the request call to be ''http://localhost:9200/_plugins/_sql?format=csv" returns:

title
Animal Farm
The Great Gatsby
Catcher In The Rye
Bohemian Rhapsody

What is your host/environment?
Present in OpenSearch 2.12, 2.11 and 1.3.10

Do you have any screenshots?
Error:
image

As expected (When adding ?format=csv to request URL):
image

Do you have any additional context?
Add any other context about the problem.

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 at the OpenSearch SQL plugin's _plugins/_sql endpoint and compare the default response path with the format=csv path for the UNION query shown. Reproduce the NullPointerException with the JSON response, then verify that the same UNION query returns its expected rows without requiring the CSV parameter.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.