Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Nested Function Behaviour in SELECT Clause Does Nothing #1489

Closed
forestmvey opened this issue Mar 30, 2023 · 0 comments
Closed

[BUG] Nested Function Behaviour in SELECT Clause Does Nothing #1489

forestmvey opened this issue Mar 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@forestmvey
Copy link
Collaborator

What is the bug?
When the nested function is used in the SELECT clause there is no use for the condition parameter. The parameter is accepted by the SQL plugin but fails to provide any use.

Both of these queries provide the same explain results:

"query":"SELECT nested(message.info, message.info = 'a') FROM nested_objects;"
"query":"SELECT nested(message.info) FROM nested_objects;"
-----------------------------------------------------------------------------------
{
    "size": 20,
    "query": {
        "bool": {
            "filter": [
                {
                    "bool": {
                        "must": [
                            {
                                "nested": {
                                    "query": {
                                        "match_all": {
                                            "boost": 1.0
                                        }
                                    },
                                    "path": "message.info",
                                    "ignore_unmapped": false,
                                    "score_mode": "none",
                                    "boost": 1.0,
                                    "inner_hits": {
                                        "ignore_unmapped": false,
                                        "from": 0,
                                        "size": 3,
                                        "version": false,
                                        "seq_no_primary_term": false,
                                        "explain": false,
                                        "track_scores": false,
                                        "_source": {
                                            "includes": [
                                                "message.info"
                                            ],
                                            "excludes": []
                                        }
                                    }
                                }
                            }
                        ],
                        "adjust_pure_negative": true,
                        "boost": 1.0
                    }
                }
            ],
            "adjust_pure_negative": true,
            "boost": 1.0
        }
    },
    "_source": {
        "includes": [],
        "excludes": []
    }
}

The query that uses the condition parameter produces this output:

{
"query":"SELECT nested(message.info, message.info = 'a') FROM nested_objects;"
------------------------------------------------------------------------------------
    "error": {
        "reason": "Error occurred in OpenSearch engine: all shards failed",
        "details": "Shard[0]: [nested_objects/ZBVd7ZztRHqLSD0XW_vVNA] QueryShardException[failed to create query: [nested] failed to find nested object under path [message.info]]; nested: IllegalStateException[[nested] failed to find nested object under path [message.info]];\n\nFor more details, please send request for Json format to see the raw response from OpenSearch engine.",
        "type": "SearchPhaseExecutionException"
    },
    "status": 400
}

The query without the condition parameter produces this output:

"query":"SELECT nested(message.info) FROM nested_objects;"
----------------------------------------------------------------
{
    "schema": [
        {
            "name": "message.info",
            "type": "keyword"
        }
    ],
    "total": 6,
    "datarows": [
        [
            "a"
        ],
        [
            "b"
        ],
        [
            "c"
        ],
        [
            "c"
        ],
        [
            "a"
        ],
        [
            "zz"
        ]
    ],
    "size": 6,
    "status": 200
}

It appears that the condition parameter for the nested function has no use when used in the SELECT clause.

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

  1. Enter query into SQL plugin - "SELECT nested(message.info, message.info = 'a') FROM nested_objects;"
  2. See error.

What is the expected behavior?
SQL plugin should not accept the condition parameter for the nested function when the function is used in the SELECT clause.

What is your host/environment?

  • OS: MacOS
  • Version 13.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants