-
-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redefine MySQL Interval segment (#2351)
* fix #2224 by redefining interval segment for mysql * fix based on PR comments Co-authored-by: Barry Pollard <barry@tunetheweb.com>
- Loading branch information
1 parent
3196b6c
commit a50ccd8
Showing
3 changed files
with
270 additions
and
0 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
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,23 @@ | ||
SELECT DATE_ADD(CURDATE(), INTERVAL -30 DAY); | ||
|
||
SELECT SUBDATE('2008-01-02', INTERVAL 31 DAY); | ||
|
||
SELECT ADDDATE(CURDATE(), INTERVAL -30 DAY); | ||
|
||
SELECT DATE_SUB('1992-12-31 23:59:59.000002', INTERVAL '1.999999' SECOND_MICROSECOND); | ||
|
||
SELECT DATE_ADD('2100-12-31 23:59:59', INTERVAL '1:1' MINUTE_SECOND); | ||
|
||
SELECT DATE_ADD(CURDATE(), INTERVAL 7 * 4 DAY); | ||
|
||
SELECT | ||
ADDDATE(CURDATE(), INTERVAL col1 DAY) | ||
FROM | ||
tbl1 | ||
; | ||
|
||
SELECT | ||
SUBDATE(CURDATE(), INTERVAL col1 + col2 DAY) | ||
FROM | ||
tbl1 | ||
; |
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,225 @@ | ||
# YML test files are auto-generated from SQL files and should not be edited by | ||
# hand. To help enforce this, the "hash" field in the file must match a hash | ||
# computed by SQLFluff when running the tests. Please run | ||
# `python test/generate_parse_fixture_yml.py` to generate them after adding or | ||
# altering SQL files. | ||
_hash: 16fde14028919875d259e244f9620226a249cd1f78ee8a5eeaaa97160399107a | ||
file: | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: DATE_ADD | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: CURDATE | ||
bracketed: | ||
start_bracket: ( | ||
end_bracket: ) | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
numeric_literal: | ||
binary_operator: '-' | ||
literal: '30' | ||
date_part: DAY | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: SUBDATE | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
literal: "'2008-01-02'" | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
literal: '31' | ||
date_part: DAY | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: ADDDATE | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: CURDATE | ||
bracketed: | ||
start_bracket: ( | ||
end_bracket: ) | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
numeric_literal: | ||
binary_operator: '-' | ||
literal: '30' | ||
date_part: DAY | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: DATE_SUB | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
literal: "'1992-12-31 23:59:59.000002'" | ||
- comma: ',' | ||
- expression: | ||
keyword: INTERVAL | ||
literal: "'1.999999'" | ||
- expression: | ||
column_reference: | ||
identifier: SECOND_MICROSECOND | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: DATE_ADD | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
literal: "'2100-12-31 23:59:59'" | ||
- comma: ',' | ||
- expression: | ||
keyword: INTERVAL | ||
literal: "'1:1'" | ||
- expression: | ||
column_reference: | ||
identifier: MINUTE_SECOND | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: DATE_ADD | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: CURDATE | ||
bracketed: | ||
start_bracket: ( | ||
end_bracket: ) | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
- literal: '7' | ||
- binary_operator: '*' | ||
- literal: '4' | ||
date_part: DAY | ||
- end_bracket: ) | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: ADDDATE | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: CURDATE | ||
bracketed: | ||
start_bracket: ( | ||
end_bracket: ) | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
column_reference: | ||
identifier: col1 | ||
date_part: DAY | ||
- end_bracket: ) | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: tbl1 | ||
- statement_terminator: ; | ||
- statement: | ||
select_statement: | ||
select_clause: | ||
keyword: SELECT | ||
select_clause_element: | ||
function: | ||
function_name: | ||
function_name_identifier: SUBDATE | ||
bracketed: | ||
- start_bracket: ( | ||
- expression: | ||
function: | ||
function_name: | ||
function_name_identifier: CURDATE | ||
bracketed: | ||
start_bracket: ( | ||
end_bracket: ) | ||
- comma: ',' | ||
- expression: | ||
interval_expression: | ||
keyword: INTERVAL | ||
expression: | ||
- column_reference: | ||
identifier: col1 | ||
- binary_operator: + | ||
- column_reference: | ||
identifier: col2 | ||
date_part: DAY | ||
- end_bracket: ) | ||
from_clause: | ||
keyword: FROM | ||
from_expression: | ||
from_expression_element: | ||
table_expression: | ||
table_reference: | ||
identifier: tbl1 | ||
- statement_terminator: ; |