Skip to content

Commit

Permalink
fix data trunc supported types
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesdevil committed Jul 13, 2022
1 parent b6b2fb0 commit 74c1838
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/ast/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ pub fn expr_element(i: Input) -> IResult<WithSpan<ExprElement>> {
| #cast : "`CAST(... AS ...)`"
| #date_add: "`DATE_ADD(..., ..., (YEAR| MONTH | DAY | HOUR | MINUTE | SECOND | DOY | DOW))`"
| #date_sub: "`DATE_SUB(..., ..., (YEAR| MONTH | DAY | HOUR | MINUTE | SECOND | DOY | DOW))`"
| #date_trunc: "`DATE_TRUNC((YEAR | MONTH | DAY | HOUR | MINUTE | SECOND | DOY | DOW), ...)`"
| #date_trunc: "`DATE_TRUNC((YEAR | MONTH | DAY | HOUR | MINUTE | SECOND), ...)`"
| #interval: "`INTERVAL ... (YEAR| MONTH | DAY | HOUR | MINUTE | SECOND | DOY | DOW)`"
| #pg_cast : "`::<type_name>`"
| #extract : "`EXTRACT((YEAR | MONTH | DAY | HOUR | MINUTE | SECOND) FROM ...)`"
Expand Down
1 change: 0 additions & 1 deletion common/exception/src/exception_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ build_exceptions! {
IllegalUDFFormat(2601),
UnknownUDF(2602),
UdfAlreadyExists(2603),
UnsupportedIntervalKind(2604),

// Database error codes.
UnknownDatabaseEngine(2701),
Expand Down
2 changes: 1 addition & 1 deletion query/src/sql/planner/semantic/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ impl<'a> TypeChecker<'a> {
)
.await
}
_ => Err(ErrorCode::UnsupportedIntervalKind("Only these interval types are currently supported: year, month, day, hour, minute, second")),
_ => Err(ErrorCode::SemanticError(span.display_error("Only these interval types are currently supported: [year, month, day, hour, minute, second]".to_string()))),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@ ERROR 1105 (HY000) at line 8: Code: 1065, displayText = error:
| ^ column doesn't exist

.
ERROR 1105 (HY000) at line 10: Code: 1065, displayText = error:
--> SQL:1:8
|
1 | select date_trunc(doy, to_date('2022-07-07'))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Only these interval types are currently supported: [year, month, day, hour, minute, second]

.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ select aa from t;
select *;
create table t1(a int);
create table t2(a int);
select a as b from t1 intersect select a as b from t2 order by a;
select a as b from t1 intersect select a as b from t2 order by a;

select date_trunc(doy, to_date('2022-07-07'));

0 comments on commit 74c1838

Please sign in to comment.