Skip to content

EXIST() returns incorrect result when used as coordinate arguments to CONTAINS(GEOPOLY2D()) #4891

Description

@cjhewett

Bug description

What happened:
CONTAINS(GEOPOLY2D(...), latitude, longitude) correctly returns 1 for a point inside the polygon.

However, wrapping the same attributes with EXIST() causes CONTAINS() to incorrectly return 0:

What you expected to happen:
I expected these two expressions to return the same result:

CONTAINS(GEOPOLY2D(...), latitude, longitude)

and:

CONTAINS(
    GEOPOLY2D(...),
    EXIST('latitude', 0),
    EXIST('longitude', 0)
)

Since EXIST('latitude', 0) and EXIST('longitude', 0) return the same values as the underlying attributes, both should return 1 for a point contained by the polygon.

Steps to reproduce:

CREATE TABLE geo_test (
    latitude FLOAT,
    longitude FLOAT
);

INSERT INTO geo_test (id, latitude, longitude)
VALUES (1, 53.481319, -2.251460);

SELECT
    latitude,
    longitude,

    CONTAINS(
        GEOPOLY2D(
            53.3,-2.5,
            53.7,-2.5,
            53.7,-2.0,
            53.3,-2.0
        ),
        latitude,
        longitude
    ) AS direct_match,

    CONTAINS(
        GEOPOLY2D(
            53.3,-2.5,
            53.7,-2.5,
            53.7,-2.0,
            53.3,-2.0
        ),
        EXIST('latitude', 0),
        EXIST('longitude', 0)
    ) AS exist_match,

    EXIST('latitude', 0) AS exist_latitude,
    EXIST('longitude', 0) AS exist_longitude

FROM geo_test;

Expected:

direct_match = 1
exist_match = 1

Actual:

direct_match = 1
exist_match = 0

Manticore Search version

28.4.4 f63d06ecb@26071006.

Operating system version

Rocky 8

Have you tried the latest development version?

Not practical / not applicable

How does this bug affect you?

Minor issue / no significant operational impact

How do you use Manticore Search?

No response

What do you use Manticore for?

No response

Company or project

No response

Approximate scale

No response

Can we learn more about your use case?

  • Yes — feel free to @mention me in this issue if you'd like to ask more about how we use Manticore.

Internal Checklist

To be completed by the assignee. Check off tasks that have been completed or are not applicable.

Details - [ ] Implementation completed - [ ] Tests developed - [ ] Documentation updated - [ ] Documentation reviewed

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions