Skip to content

Conversation

@xiangfu0
Copy link
Contributor

@xiangfu0 xiangfu0 commented Oct 3, 2023

Current stPoint only supports boolean as 3rd argument, this is not aligned with Transformer function which can be either INT or BOOLEAN.

  1. Make Scalar function signature for stPoint to use Object as 3rd argument
  2. Update StPoint registration in TransformFunctionType
  3. Support both BYTES and STRING in H3IndexFilterOperator to handle binary literal values.
  4. Add test for v2 intermediate stage in org.apache.pinot.integration.tests.custom.GeoSpatialTest

@xiangfu0 xiangfu0 added backward-incompat Referenced by PRs that introduce or fix backward compat issues geo multi-stage Related to the multi-stage query engine labels Oct 3, 2023
@xiangfu0 xiangfu0 changed the title Add test for StPoint and stDistance functions in intermediate stage Modify StPoint scalar function signature for v2 compatibility Oct 3, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2023

Codecov Report

❌ Patch coverage is 63.63636% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.10%. Comparing base (78fc66b) to head (e7481da).
⚠️ Report is 3124 commits behind head on master.

Files with missing lines Patch % Lines
...ot/core/operator/filter/H3IndexFilterOperator.java 40.00% 2 Missing and 1 partial ⚠️
...geospatial/transform/function/ScalarFunctions.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #11731      +/-   ##
============================================
- Coverage     63.12%   63.10%   -0.02%     
  Complexity     1118     1118              
============================================
  Files          2342     2342              
  Lines        125889   125924      +35     
  Branches      19360    19364       +4     
============================================
+ Hits          79462    79469       +7     
- Misses        40783    40799      +16     
- Partials       5644     5656      +12     
Flag Coverage Δ
integration <0.01% <0.00%> (ø)
integration1 <0.01% <0.00%> (ø)
integration2 0.00% <0.00%> (ø)
java-11 50.13% <63.63%> (-12.93%) ⬇️
java-17 62.95% <63.63%> (-0.03%) ⬇️
java-20 62.95% <63.63%> (-0.01%) ⬇️
temurin 63.10% <63.63%> (-0.02%) ⬇️
unittests 63.10% <63.63%> (-0.02%) ⬇️
unittests1 67.25% <63.63%> (-0.04%) ⬇️
unittests2 14.43% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xiangfu0 xiangfu0 force-pushed the fixing-binary-intermediate-stage branch from db36255 to 35d3db4 Compare October 3, 2023 21:16
@xiangfu0 xiangfu0 force-pushed the fixing-binary-intermediate-stage branch 3 times, most recently from 3bb7b74 to ad55f9f Compare October 3, 2023 23:11
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.ANY),
OperandTypes.or(
OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC)),
OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.BOOLEAN))
),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

somehow this doesn't honor ordinal -> ordinal > 1 && ordinal < 4 to handle variable number of parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I try to define this as:

  ST_POINT("ST_Point", ReturnTypes.explicit(SqlTypeName.VARBINARY),
      OperandTypes.or(
          OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
              ordinal -> ordinal > 1 && ordinal < 4),
          OperandTypes.family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC, SqlTypeFamily.BOOLEAN),
              ordinal -> ordinal > 1 && ordinal < 4)),
      "stPoint"),

The StPoint(1,2) will fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah. i see. that's fine for now

@xiangfu0 xiangfu0 force-pushed the fixing-binary-intermediate-stage branch 2 times, most recently from 702a0a5 to 8b03ee5 Compare October 4, 2023 04:21
@xiangfu0 xiangfu0 force-pushed the fixing-binary-intermediate-stage branch from 8b03ee5 to e7481da Compare October 4, 2023 07:43
@xiangfu0 xiangfu0 requested a review from walterddr October 4, 2023 07:56
public static byte[] stPoint(double x, double y, Object isGeography) {
Point point = GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(x, y));
if (isGeography) {
if (BooleanUtils.toBoolean(isGeography)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if isGeography is not given boolean up?

Copy link
Contributor

Choose a reason for hiding this comment

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

BooleanUtils.toBoolean actually works for number/string/boolean type.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. for non-boolean value, will it handle exception?

Copy link
Contributor Author

@xiangfu0 xiangfu0 Oct 4, 2023

Choose a reason for hiding this comment

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

this is our internal boolean util, it can handle number/string/boolean

public static boolean toBoolean(Object booleanObject) {
    if (booleanObject == null) {
      return false;
    } else if (booleanObject instanceof String) {
      return BooleanUtils.toBoolean((String) booleanObject);
    } else if (booleanObject instanceof Number) {
      return ((Number) booleanObject).intValue() == INTERNAL_TRUE;
    } else if (booleanObject instanceof Boolean) {
      return (boolean) booleanObject;
    } else {
      throw new IllegalArgumentException("Illegal type for boolean conversion: " + booleanObject.getClass());
    }
  }

Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

lgtm we should add more tests for other ST later

@xiangfu0 xiangfu0 merged commit 3329d83 into apache:master Oct 4, 2023
@xiangfu0 xiangfu0 deleted the fixing-binary-intermediate-stage branch October 4, 2023 17:46
@xiangfu0 xiangfu0 removed the backward-incompat Referenced by PRs that introduce or fix backward compat issues label Oct 4, 2023
@xiangfu0 xiangfu0 changed the title Modify StPoint scalar function signature for v2 compatibility Fix StPoint scalar function usage in multi-stage engine intermediate stage Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

geo multi-stage Related to the multi-stage query engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants