Skip to content

Support AMQP SQL Filter Expressions #14184

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

Merged
merged 18 commits into from
Jul 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions deps/amqp10_common/include/amqp10_filter.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,15 @@
%%
%% Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.

%% A filter with this name contains a JMS message selector.
%% We use the same name as sent by the Qpid JMS client in
%% https://github.com/apache/qpid-jms/blob/2.7.0/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/AmqpSupport.java#L75
-define(FILTER_NAME_JMS, <<"jms-selector">>).

%% A filter with this name contains an SQL expression.
%% In the current version, such a filter must comply with the JMS message selector syntax.
%% However, we use a name other than "jms-selector" in case we want to extend the allowed syntax
%% in the future, for example allowing for some of the extended grammar described in
%% §6 "SQL Filter Expressions" of
%% https://groups.oasis-open.org/higherlogic/ws/public/document?document_id=66227
-define(FILTER_NAME_SQL, <<"sql-filter">>).

%% SQL-based filtering syntax
%% These descriptors are defined in
%% https://www.amqp.org/specification/1.0/filters
-define(DESCRIPTOR_NAME_SELECTOR_FILTER, <<"apache.org:selector-filter:string">>).
-define(DESCRIPTOR_CODE_SELECTOR_FILTER, 16#0000468C00000004).

%% AMQP Filter Expressions Version 1.0 Working Draft 09
%% https://groups.oasis-open.org/higherlogic/ws/public/document?document_id=66227
%% AMQP Filter Expressions Version 1.0 Committee Specification Draft 01
%% https://docs.oasis-open.org/amqp/filtex/v1.0/csd01/filtex-v1.0-csd01.html#_Toc67929266
-define(DESCRIPTOR_NAME_PROPERTIES_FILTER, <<"amqp:properties-filter">>).
-define(DESCRIPTOR_CODE_PROPERTIES_FILTER, 16#173).
-define(DESCRIPTOR_NAME_APPLICATION_PROPERTIES_FILTER, <<"amqp:application-properties-filter">>).
-define(DESCRIPTOR_CODE_APPLICATION_PROPERTIES_FILTER, 16#174).

%% A filter with this name contains an AMQP SQL expression.
-define(FILTER_NAME_SQL, <<"sql-filter">>).
%% https://docs.oasis-open.org/amqp/filtex/v1.0/csd01/filtex-v1.0-csd01.html#_Toc67929276
-define(DESCRIPTOR_NAME_SQL_FILTER, <<"amqp:sql-filter">>).
-define(DESCRIPTOR_CODE_SQL_FILTER, 16#120).
2 changes: 1 addition & 1 deletion deps/rabbit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ define ct_master.erl
endef

PARALLEL_CT_SET_1_A = unit_rabbit_ssl unit_cluster_formation_locking_mocks unit_cluster_formation_sort_nodes unit_collections unit_config_value_encryption unit_connection_tracking
PARALLEL_CT_SET_1_B = amqp_address amqp_auth amqp_credit_api_v2 amqp_filter_prop amqp_filter_sql amqp_jms_unit amqp_dotnet amqp_jms signal_handling single_active_consumer unit_access_control_authn_authz_context_propagation unit_access_control_credential_validation unit_amqp091_content_framing unit_amqp091_server_properties unit_app_management
PARALLEL_CT_SET_1_B = amqp_address amqp_auth amqp_credit_api_v2 amqp_filter_prop amqp_filter_sql amqp_filter_sql_unit amqp_dotnet amqp_jms signal_handling single_active_consumer unit_access_control_authn_authz_context_propagation unit_access_control_credential_validation unit_amqp091_content_framing unit_amqp091_server_properties unit_app_management
PARALLEL_CT_SET_1_C = amqp_proxy_protocol amqpl_consumer_ack amqpl_direct_reply_to backing_queue bindings rabbit_db_maintenance rabbit_db_msup rabbit_db_policy rabbit_db_queue rabbit_db_topic_exchange rabbit_direct_reply_to_prop cluster_limit cluster_minority term_to_binary_compat_prop topic_permission transactions unicode unit_access_control
PARALLEL_CT_SET_1_D = amqqueue_backward_compatibility channel_interceptor channel_operation_timeout classic_queue classic_queue_prop config_schema peer_discovery_dns peer_discovery_tmp_hidden_node per_node_limit per_user_connection_channel_limit

Expand Down
6 changes: 3 additions & 3 deletions deps/rabbit/src/rabbit_amqp_filter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

-type expression() :: undefined |
{property, rabbit_amqp_filter_prop:parsed_expressions()} |
{jms, rabbit_amqp_filter_jms:parsed_expression()}.
{sql, rabbit_amqp_filter_sql:parsed_expression()}.

-export_type([expression/0]).

Expand All @@ -20,5 +20,5 @@ eval(undefined, _Mc) ->
true;
eval({property, Expr}, Mc) ->
rabbit_amqp_filter_prop:eval(Expr, Mc);
eval({jms, Expr}, Mc) ->
rabbit_amqp_filter_jms:eval(Expr, Mc).
eval({sql, Expr}, Mc) ->
rabbit_amqp_filter_sql:eval(Expr, Mc).
Loading
Loading