forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](Nereids) fix date function rewrite on datetimev1 column bug apa…
…che#32569 (apache#32719) cherry picked from apache#32569
- Loading branch information
Showing
3 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
regression-test/data/datatype_p0/datetimev1/test_datetimev1_date_function.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !date_function_test_datetimev1_gt -- | ||
2020-01-06T21:02:03 | ||
2020-01-07T09:29:39 | ||
2020-01-08T11:33:55 | ||
2020-01-09T14:43:42 | ||
2020-01-10T23:59:59 | ||
|
||
-- !date_function_test_datetimev1_gte -- | ||
2020-01-05T17:58:59 | ||
2020-01-06T21:02:03 | ||
2020-01-07T09:29:39 | ||
2020-01-08T11:33:55 | ||
2020-01-09T14:43:42 | ||
2020-01-10T23:59:59 | ||
|
||
-- !date_function_test_datetimev1_lt -- | ||
2020-01-01T19:29:39 | ||
2020-01-02T18:28:38 | ||
2020-01-03T23:37:47 | ||
2020-01-04T21:42:43 | ||
|
||
-- !date_function_test_datetimev1_lte -- | ||
2020-01-01T19:29:39 | ||
2020-01-02T18:28:38 | ||
2020-01-03T23:37:47 | ||
2020-01-04T21:42:43 | ||
2020-01-05T17:58:59 | ||
|
||
-- !date_function_test_datetimev1_eq -- | ||
2020-01-05T17:58:59 | ||
|
124 changes: 124 additions & 0 deletions
124
regression-test/suites/datatype_p0/datetimev1/test_datetimev1_date_function.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_datetimev1_date_function", "nonConcurrent") { | ||
|
||
/// legacy date/datetime format need to run in non concurrent mode. | ||
sql """ | ||
admin set frontend config("enable_date_conversion" = "false"); | ||
""" | ||
|
||
def table_dup = "test_datetimev1_date_function_dup_tbl" // duplicate key | ||
|
||
sql "drop table if exists ${table_dup};" | ||
|
||
sql """ | ||
CREATE TABLE IF NOT EXISTS `${table_dup}` ( | ||
`date_key1` datetimev1 NULL COMMENT "", | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`date_key1`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`date_key1`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"in_memory" = "false", | ||
"storage_format" = "V2" | ||
) | ||
""" | ||
|
||
def insert_data = { table_name -> | ||
sql """ | ||
insert into ${table_name} | ||
values | ||
('2020-01-01 19:29:39'), | ||
('2020-01-02 18:28:38'), | ||
('2020-01-03 23:37:47'), | ||
('2020-01-04 21:42:43'), | ||
('2020-01-05 17:58:59'), | ||
('2020-01-06 21:02:03'), | ||
('2020-01-07 09:29:39'), | ||
('2020-01-08 11:33:55'), | ||
('2020-01-09 14:43:42'), | ||
('2020-01-10 23:59:59'); | ||
""" | ||
} | ||
|
||
insert_data(table_dup) | ||
|
||
def run_compare_test = { table_name, col, col_value -> | ||
def query1 = """ | ||
select | ||
* | ||
from | ||
`${table_name}` | ||
where | ||
date(`${col}`) > ${col_value} | ||
order by 1; | ||
""" | ||
quickTest("date_function_test_datetimev1_gt", query1) | ||
|
||
def query2 = """ | ||
select | ||
* | ||
from | ||
`${table_name}` | ||
where | ||
date(`${col}`) >= ${col_value} | ||
order by 1; | ||
""" | ||
quickTest("date_function_test_datetimev1_gte", query2) | ||
|
||
def query3 = """ | ||
select | ||
* | ||
from | ||
`${table_name}` | ||
where | ||
date(`${col}`) < ${col_value} | ||
order by 1; | ||
""" | ||
quickTest("date_function_test_datetimev1_lt", query3) | ||
|
||
def query4 = """ | ||
select | ||
* | ||
from | ||
`${table_name}` | ||
where | ||
date(`${col}`) <= ${col_value} | ||
order by 1; | ||
""" | ||
quickTest("date_function_test_datetimev1_lte", query4) | ||
|
||
def query5 = """ | ||
select | ||
* | ||
from | ||
`${table_name}` | ||
where | ||
date(`${col}`) = ${col_value} | ||
order by 1; | ||
""" | ||
quickTest("date_function_test_datetimev1_eq", query5) | ||
} | ||
|
||
run_compare_test(table_dup, "date_key1", "'2020-01-05'") | ||
|
||
sql """ | ||
admin set frontend config("enable_date_conversion" = "true"); | ||
""" | ||
} |