Skip to content

DM-55424: Support scisql_s2PtInCircle Spatial Joins and scisql_angSep Area Restrictors#1032

Draft
malensek wants to merge 5 commits into
tickets/DM-43715from
tickets/DM-55424
Draft

DM-55424: Support scisql_s2PtInCircle Spatial Joins and scisql_angSep Area Restrictors#1032
malensek wants to merge 5 commits into
tickets/DM-43715from
tickets/DM-55424

Conversation

@malensek

Copy link
Copy Markdown
Member

Currently, Qserv infers spatial join conditions only from appropriately formed scisql_angSep expressions. These conditions could, however, also validly be expressed in terms of scisql_s2PtInCircle. Similarly, a query can express an area restriction (cone evaluated against a single director table) using scisql_angSep instead of scisql_s2PtInCircle, as long as one side of the coordinate pair is a constant. For example:
WHERE scisql_angSep(dias.coord_ra, dias.coord_dec, 55.5, -30.2) < 0.05
is equivalent to
WHERE scisql_s2PtInCircle(dias.coord_ra, dias.coord_dec, 55.5, -30.2, 0.05) = 1
which Qserv already recognizes as an area restrictor.

This PR adds the missing direction for both, so either scisql form can be used interchangeably for spatial joins and area restrictors.

Summary of Changes

  • RelationGraph.cc - _addSpEdges now tries scisql_angSep first, then falls back to the equivalent scisql_s2PtInCircle(...) = 1 form. Refactored the per-form extraction logic. Improved error reporting in the case of malformed queries.
  • QservRestrictorPlugin.cc - extractSingleAreaRestrictor now also recognizes scisql_angSep(lon, lat, constLon, constLat) <= radius as equivalent to scisql_s2PtInCircle(...) = 1, producing the same AreaRestrictorCircle.
  • testQueryAnaGeneral.cc - new test coverage for the features described above

@malensek malensek changed the title DM-55424: Support scisql_s2PtInCircle-based Spatial Joins and scisql_angSep-based Area Restrictors DM-55424: Support scisql_s2PtInCircle Spatial Joins and scisql_angSep Area Restrictors Jul 13, 2026
@malensek malensek requested a review from Copilot July 13, 2026 21:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Qserv’s query analysis so that spatial joins and cone/area restrictors can be inferred from either scisql_angSep(...) OP radius or the equivalent scisql_s2PtInCircle(..., radius) = 1 form, improving interoperability between the two scisql idioms.

Changes:

  • Add ValueExpr::getNumericConst() to centralize numeric-constant extraction used by spatial inference.
  • Refactor RelationGraph::_addSpEdges to infer spatial joins from scisql_angSep first, then fall back to scisql_s2PtInCircle(...)=1.
  • Extend QservRestrictorPlugin to recognize scisql_angSep(..., constLon, constLat) <(=) radius as an area restrictor, and add/expand unit tests covering the new forms and error cases.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/query/ValueExpr.h Declares new helper for extracting numeric constants from ValueExpr.
src/query/ValueExpr.cc Implements getNumericConst() used by join/restrictor inference.
src/qana/RelationGraph.cc Adds/refactors scisql predicate extraction to support pt-in-circle spatial joins.
src/qana/QservRestrictorPlugin.cc Adds scisql_angSep-based cone restrictor recognition alongside existing s2PtIn* handling.
src/qproc/testQueryAnaGeneral.cc Adds coverage for pt-in-circle joins, angSep cone restrictors, and negative-threshold error cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/query/ValueExpr.cc
Comment thread src/qana/RelationGraph.cc
Comment thread src/qana/RelationGraph.cc Outdated
Comment thread src/qana/RelationGraph.cc Outdated
malensek added 3 commits July 13, 2026 14:40
This functionality was duplicated between QservRestrictorPlugin and
RelationGraph, so we'll centrally locate it here.
Previously scisql_angSep could not be used to express an area
restriction even though a call to scisql_angSep with a single set of
constant coordinate pairs can be rewritten as an equivalent
scisql_s2PtInCircle area restrictor. This change allows
appropriately-formed scisql_angSep calls to be automatically converted
to a circular area restrictor.
This is already provided by the ValueExpr::getNumericConst() method.
malensek added 2 commits July 14, 2026 10:24
Previously spatial joins were limited to scisql_angSep constructs. This
allows queries to be expressed in equivalent scisql_s2PtInCircle form.
Previous constraints remain (coordinate pairs must come from different
table refs, but their columns must come from the same table ref, both
column pairs must be found in director tables, and the directors must
have the same partitioning).

This includes a minor refactor to split checks for the two scisql
functions into separate helper functions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment thread src/qana/QservRestrictorPlugin.cc
Comment thread src/qana/RelationGraph.cc
Comment on lines +333 to +347
case query::CompPredicate::EQUALS_OP:
case query::CompPredicate::NULL_SAFE_EQUALS_OP:
case query::CompPredicate::NOT_EQUALS_OP:
case query::CompPredicate::NOT_EQUALS_OP_ALT:
// While this doesn't make much sense numerically (floating
// point numbers are being tested for equality), it is
// technically evaluable.
fe = getAngSepFunc(cp.left);
if (!fe) {
angSep = cp.left->getNumericConst();
fe = getAngSepFunc(cp.right);
} else {
angSep = cp.right->getNumericConst();
}
break;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was how it worked before this PR (just relocated), so I guess this definitely warrants some discussion...

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants