Change compare logical when comparing date related fields with string literal#3798
Conversation
|
Please add a test case in |
Already add one in CalcitePPLExplainIT |
Please use |
|
Please update the PR description to add the Calcite physical plans before and after this patching. |
| return doubleValue(); | ||
| } else if (isBoolean()) { | ||
| return booleanValue(); | ||
| } else if (isTimestamp()) { |
There was a problem hiding this comment.
what if date/string comparing in a filter?
There was a problem hiding this comment.
Date still needs to use timestamp to convert since we need to align with V2. We need to support something like date('2020-10-20') = '2020-10-20 00:00:00' since v2 will do the implicit conversion. So compare date/string cannot be pushed down.
There was a problem hiding this comment.
Do you mean date/string comparing in a filter can pushdown in v2, not cannot in v3?
There was a problem hiding this comment.
Already change and now date/string, time/string can be pushed down as V2.
| var result = | ||
| explainQueryToString( | ||
| String.format( | ||
| "source=%s | where birthdate < '2017-11-20 00:00:00'", |
There was a problem hiding this comment.
source = big5 | where `@timestamp` >= '2023-01-01 00:00:00.000000000' and `@timestamp` < '2023-01-03 00:00:00.000000000'
Here is an example of big5 query, can you test with similar usage?
There was a problem hiding this comment.
Yes. Already add IT like this one.
There was a problem hiding this comment.
IMO, the case I listed was diff with the one you added. Please try where birthdate < '2018-11-09 00:00:00.000000000'
There was a problem hiding this comment.
Got it. Already change it with nano second.
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
This reverts commit f3b53af. Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
be17d6d to
8720c74
Compare
|
Force push to resolve dco problem |
Already done. Please check it. |
Already put it in correct place. Please check it. |
Signed-off-by: xinyual <xinyual@amazon.com>
|
ping @qianheng-aws |
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
| } | ||
| } | ||
|
|
||
| public static RexNode transferCompareForDateRelated( |
There was a problem hiding this comment.
please add javadoc for public static methods
| return candidate; | ||
| } | ||
|
|
||
| public static SqlTypeName findCastType(RexNode left, RexNode right) { |
| return leftType == null ? rightType : leftType; | ||
| } | ||
|
|
||
| public static SqlTypeName returnCorrespondingSqlType(RexNode node) { |
Signed-off-by: xinyual <xinyual@amazon.com>
Signed-off-by: xinyual <xinyual@amazon.com>
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.19-dev 2.19-dev
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.19-dev
# Create a new branch
git switch --create backport/backport-3798-to-2.19-dev
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 22a88d105ce75ce740476610b9e5a8dacf4f71be
# Push it to GitHub
git push --set-upstream origin backport/backport-3798-to-2.19-dev
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.19-devThen, create a pull request where the |
|
@xinyual could you manually backport it to 2.19-dev? |
Description
The PR change the logical when compare with date/time/timestamp with a string literal to align with V2. Now we will cast the string literal to date/time/timestamp according to the compare target so it can be pushed down.
For example, previous, if we compare date < '2020-10-20 12:00:00', we will cast date to timestamp and append 00:00:00 to the date so they can compare. Now we cast the string literal to date as '2020-10-20'. Same as time.
For ppl like
for example,
The calcite physical plan change from
to
same as time/date,
for date, the physical plan of PPL
from
to
for time, the physical plan of PPL
from
to
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
#3710
Check List
--signoff.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.