Skip to content

Conversation

@HappenLee
Copy link
Contributor

Decimal should have high match priority than varcher.

issue: #4665

Proposed changes

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Types of changes

What types of changes does your code introduce to Doris?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • [] New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] Documentation Update (if none of the other choices apply)
  • [] Code refactor (Modify the code structure, format the code, etc...)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have create an issue on (Fix #ISSUE), and have described the bug/feature there in detail
  • Compiling and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • If this change need a document change, I have updated the document
  • Any dependent changes have been merged

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

morningman
morningman previously approved these changes Sep 27, 2020
Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman added approved Indicates a PR has been approved by one committer. area/sql/function Issues or PRs related to the SQL functions kind/fix Categorizes issue or PR as related to a bug. labels Sep 27, 2020
@kangkaisen
Copy link
Contributor

I think a more simple way to fix this issue is:

     @Override
     protected Expr uncheckedCastTo(Type targetType) throws AnalysisException {
-        if (targetType.isFloatingPointType()) {
+        if (targetType.isDecimal() || targetType.isDecimalV2()) {
+            return this;
+        } else if (targetType.isFloatingPointType()) {

@@ -769,7 +749,9 @@ public class FunctionSet {
         final Type[] candicateArgTypes = candicate.getArgs();
         if (functionName.equalsIgnoreCase("hex")
                 || functionName.equalsIgnoreCase("greast")
-                || functionName.equalsIgnoreCase("least")) {
+                || functionName.equalsIgnoreCase("least")
+                || functionName.equalsIgnoreCase("lead")
+                || functionName.equalsIgnoreCase("lag")) {

My fixed way has been passed a lot of tests.

@kangkaisen
Copy link
Contributor

Besides,you should add a UT for this bug.

@HappenLee
Copy link
Contributor Author

I think a more simple way to fix this issue is:

     @Override
     protected Expr uncheckedCastTo(Type targetType) throws AnalysisException {
-        if (targetType.isFloatingPointType()) {
+        if (targetType.isDecimal() || targetType.isDecimalV2()) {
+            return this;
+        } else if (targetType.isFloatingPointType()) {

@@ -769,7 +749,9 @@ public class FunctionSet {
         final Type[] candicateArgTypes = candicate.getArgs();
         if (functionName.equalsIgnoreCase("hex")
                 || functionName.equalsIgnoreCase("greast")
-                || functionName.equalsIgnoreCase("least")) {
+                || functionName.equalsIgnoreCase("least")
+                || functionName.equalsIgnoreCase("lead")
+                || functionName.equalsIgnoreCase("lag")) {

My fixed way has been passed a lot of tests.

Thanks,I will check again the repair way again.

@morningman morningman removed the approved Indicates a PR has been approved by one committer. label Sep 28, 2020
Add lag() and lead() char and varchar check in `isCastMatchAllowed`.

issue: apache#4665
Copy link
Contributor

@kangkaisen kangkaisen left a comment

Choose a reason for hiding this comment

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

+1

@kangkaisen kangkaisen added the approved Indicates a PR has been approved by one committer. label Sep 28, 2020
@morningman morningman merged commit f0bb012 into apache:master Oct 4, 2020
@yangzhg yangzhg mentioned this pull request Feb 9, 2021
yiguolei pushed a commit to yiguolei/incubator-doris that referenced this pull request Sep 28, 2025
…ble apache#56074 (apache#4666)

cherry-picks from apache#56074
Related to apache#4562

Co-authored-by: Yongqiang YANG <yangyongqiang@selectdb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. area/sql/function Issues or PRs related to the SQL functions kind/fix Categorizes issue or PR as related to a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants