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

Filtered Subscription with LIKE / EQ condition and a parameter #4199

Closed
1 task done
p2k-ko opened this issue Dec 30, 2023 · 3 comments
Closed
1 task done

Filtered Subscription with LIKE / EQ condition and a parameter #4199

p2k-ko opened this issue Dec 30, 2023 · 3 comments
Labels

Comments

@p2k-ko
Copy link

p2k-ko commented Dec 30, 2023

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

During evaluation of FastDDS I tried to create a filtered subscription based on a STRING value. According to the documentation: DefaultFilter the string may be compared with LIKE/MATCH or EQUALS.

If the check for the color is added to the filter of the ShapesDemo ShapeSubscriber the following variants should behave identically:

  1. Fixed color within filter expression
static uint64_t filter_index = 0;
        //const std::string color = "RED";
        std::vector<std::string> parameters;
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_minX));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_maxX));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_minY));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_maxY));
        // parameters.emplace_back(color);

        mp_filtered_topic = mp_sd->getParticipant()->create_contentfilteredtopic(
            std::to_string(filter_index++), mp_topic,
            "x > %0 AND x < %1 AND y > %2 AND y < %3 AND color = 'RED'", parameters);
  1. Color supplied as a parameter to the filter
        static uint64_t filter_index = 0;
        const std::string color = "RED";                
        std::vector<std::string> parameters;
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_minX));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_maxX));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_minY));
        parameters.emplace_back(std::to_string(m_shapeHistory.m_filter.m_maxY));
        parameters.emplace_back(color);

        mp_filtered_topic = mp_sd->getParticipant()->create_contentfilteredtopic(
            std::to_string(filter_index++), mp_topic,
            "x > %0 AND x < %1 AND y > %2 AND y < %3 AND color = '%4'", parameters);

Both filters should filter the samples of the selected shape topic if the position is within the boundaries and the color is RED.

Current behavior

  1. Fixed color within filter expression

If the color is fixed within the filter expression the subscription works as expected. Only the shapes with the RED color within the boundaries are filtered.

  1. Color supplied as a parameter to the filter

If the color is provided as a parameter the subscription does not yield any samples of the RED shape.

Steps to reproduce

  • Create a Filter with a STRING variable e.g. ""x > %0 AND x < %1 AND y > %2 AND y < %3 AND color = '%4'"
  • Provide the filter value as a parameter
  • Start a publisher
  • Start the matching subscriber with the content filter
    Example available at : https://github.com/p2k-ko/ShapesDemo/tree/issue_4199

Fast DDS version/commit

commit 7195ede

Platform/Architecture

Other. Please specify in Additional context section.

Transport layer

UDPv4

Additional context

Some preliminary debugging points to the DDSFilterPredicate. If the STRING value is provided as a parameter the content of the _right->string_value is "%4" instead of "RED". It seems that the parser mixes up the parameter and the LIKE expression?

Compiled on: Linux 6.1.69-1-MANJARO #1 SMP PREEMPT_DYNAMIC Thu Dec 21 12:29:38 UTC 2023 x86_64 GNU/Linux

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

@p2k-ko p2k-ko added the triage Issue pending classification label Dec 30, 2023
@MiguelCompany
Copy link
Member

Hi @p2k-ko , thank you for using Fast DDS.

You should remove the single quotes around the parameter, so your filter expression would be something like x > %0 AND x < %1 AND y > %2 AND y < %3 AND color = %4

@MiguelCompany MiguelCompany added invalid question and removed triage Issue pending classification invalid labels Jan 8, 2024
@p2k-ko
Copy link
Author

p2k-ko commented Jan 8, 2024

Yes, you are right. We had to add the single quotes to the color string. This combination works for us. This issue can be closed.

@p2k-ko
Copy link
Author

p2k-ko commented Jan 8, 2024

No bug

@p2k-ko p2k-ko closed this as completed Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants