Skip to content

[BUG] Boolean fields aren't applied as filters in WHERE clauses #3317

Closed

Description

@Swiddis

What is the bug?
Building on #3266, it turns out that variables as boolean clauses aren't applied correctly at all.

How can one reproduce the bug?

PUT test_index

POST _bulk
{ "create": { "_index": "test_index" } }
{ "x": 0, "y": false }
{ "create": { "_index": "test_index" } }
{ "x": 1, "y": true }
{ "create": { "_index": "test_index" } }
{ "x": 2, "y": null }

POST _plugins/_sql
{
  "query": "SELECT x FROM test_index WHERE y"
}
{
  "schema": [
    {
      "name": "x",
      "type": "long"
    }
  ],
  "datarows": [
    [0], [1], [2]
  ],
  "total": 3,
  "size": 3,
  "status": 200
}

What is the expected behavior?

{
  "schema": [
    {
      "name": "x",
      "type": "long"
    }
  ],
  "datarows": [
    [1]
  ],
  "total": 1,
  "size": 1,
  "status": 200
}

What is your host/environment?

Do you have any screenshots?
N/A

Do you have any additional context?
Found by dynamic-testing via NoREC. Original failure:

Falsified after 0 passed tests.
> Labels of failing property: 
39 != 15
Optimizing:     SELECT j FROM test_34761613 WHERE z
Non-Optimizing: SELECT z FROM test_34761613 
> ARG_0: SELECT j, k FROM test_34761613 WHERE z

Activity

  1. added
    bug
    dynamic-test
    and removed on Feb 11, 2025
  2. added
    PPL
    on May 29, 2025
  3. self-assigned this
    on Jun 27, 2025
  4. linked a pull request that will close this issueSupport full expression in WHERE clauses #3849on Jul 8, 2025
  5. added
    engine v2
    and removed
    PPL
    on Jul 8, 2025
  6. LantaoJin commented on Jul 8, 2025

    @LantaoJin
    Member

    After #3849 merged, the issue only could happen in v2. In v3 (enabling calcite)

    POST /_plugins/_ppl
    {
      "query": "source=test_index | WHERE y"
    }
    

    returns

    {
      "schema": [
        {
          "name": "x",
          "type": "bigint"
        },
        {
          "name": "y",
          "type": "boolean"
        }
      ],
      "datarows": [
        [
          1,
          true
        ]
      ],
      "total": 1,
      "size": 1
    }
    
  7. moved this from Not Started to Done in PPL Trackeron Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

SQLbugdynamic-testengine v2

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions