Skip to content

Conversation

@yuancu
Copy link
Collaborator

@yuancu yuancu commented Aug 1, 2025

Description

Backport #3914 to 2.19-dev

Commit Message

  • Change the use of SqlTypeFamily.STRING to SqlTypeFamily.CHARACTER as the string family contains binary, which is not expected for most functions

  • Implement basic argument type coercion at RelNode level

  • Conform type checkers with their definition in documentation

  • string as an input is removed if it is not in the document
  • string as an input is kept if it is in the document, even if it can be implicitly cast
  • use PPLOperandTypes as much as possible
  • Implement type widening for comparator functions
  • Add COMPARATORS set to BuiltinFunctionName for identifying comparison operators
  • Implement widenArguments method in CoercionUtils to find widest compatible type
  • Apply type widening to comparator functions before applying type casting
  • Add detailed JavaDoc to explain coercion methods
  • Update error messages of datetime functions with invalid args

  • Simplify datetime-string compare logic with implict coercion

  • Refactor resolve with coercion

  • Move down argument cast for reduce function

  • Merge comparators and their IP variants so that coercion works for IP comparison

  • when not merging, ip comparing will also pass the type checker of Calcite's comparators
  • Refactor ip comparator to comparator

  • Revert "Refactor ip comparator to comparator"

This reverts commit c539056.

  • Revert "Merge comparators and their IP variants so that coercion works for IP comparison"

This reverts commit bd9f3bb.

  • Rule out ip from built-in comparator via its type checker

  • Restrict CompareIP's parameter type

  • Revert to previous implementation of CompareIpFunction to temporarily fix ip comparison pushdown problems (udt not correctly serialized; ip comparison is not converted to range query)

  • Test argument coercion explain

  • Fix error msg in CalcitePPLFunctionTypeTest


(cherry picked from commit 484f49e)

Related Issues

#3761

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@yuancu yuancu force-pushed the backport/backport-3914-to-2.19-dev branch 6 times, most recently from d1382d2 to 183ecb0 Compare August 4, 2025 16:01
)

* Change the use of SqlTypeFamily.STRING to SqlTypeFamily.CHARACTER as the string family contains binary, which is not expected for most functions

Signed-off-by: Yuanchun Shen <[email protected]>

* Implement basic argument type coercion at RelNode level

Signed-off-by: Yuanchun Shen <[email protected]>

* Conform type checkers with their definition in documentation
- string as an input is removed if it is not in the document
- string as an input is kept if it is in the document, even if it can be implicitly cast
- use PPLOperandTypes as much as possible

Signed-off-by: Yuanchun Shen <[email protected]>

* Implement type widening for comparator functions

- Add COMPARATORS set to BuiltinFunctionName for identifying comparison operators
- Implement widenArguments method in CoercionUtils to find widest compatible type
- Apply type widening to comparator functions before applying type casting
- Add detailed JavaDoc to explain coercion methods

Signed-off-by: Yuanchun Shen <[email protected]>

* Update error messages of datetime functions with invalid args

Signed-off-by: Yuanchun Shen <[email protected]>

* Simplify datetime-string compare logic with implict coercion

Signed-off-by: Yuanchun Shen <[email protected]>

* Refactor resolve with coercion

Signed-off-by: Yuanchun Shen <[email protected]>

* Move down argument cast for reduce function

Signed-off-by: Yuanchun Shen <[email protected]>

* Merge comparators and their IP variants so that coercion works for IP comparison

- when not merging, ip comparing will also pass the type checker of Calcite's comparators

Signed-off-by: Yuanchun Shen <[email protected]>

* Refactor ip comparator to comparator

Signed-off-by: Yuanchun Shen <[email protected]>

* Revert "Refactor ip comparator to comparator"

This reverts commit c539056.

Signed-off-by: Yuanchun Shen <[email protected]>

* Revert "Merge comparators and their IP variants so that coercion works for IP comparison"

This reverts commit bd9f3bb.

Signed-off-by: Yuanchun Shen <[email protected]>

* Rule out ip from built-in comparator via its type checker

Signed-off-by: Yuanchun Shen <[email protected]>

* Restrict CompareIP's parameter type

Signed-off-by: Yuanchun Shen <[email protected]>

* Revert to previous implementation of CompareIpFunction to temporarily fix ip comparison pushdown problems (udt not correctly serialized; ip comparison is not converted to range query)

Signed-off-by: Yuanchun Shen <[email protected]>

* Test argument coercion explain

Signed-off-by: Yuanchun Shen <[email protected]>

* Fix error msg in CalcitePPLFunctionTypeTest

Signed-off-by: Yuanchun Shen <[email protected]>

---------

Signed-off-by: Yuanchun Shen <[email protected]>
(cherry picked from commit 484f49e)
@qianheng-aws qianheng-aws merged commit 0c0c89d into opensearch-project:2.19-dev Aug 6, 2025
24 checks passed
@yuancu yuancu deleted the backport/backport-3914-to-2.19-dev branch August 6, 2025 03:40
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.

3 participants