mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-04 22:38:01 +00:00
Postgres: Support INTERVAL
data type options (#1984)
Some checks failed
Rust / compile (push) Has been cancelled
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
Some checks failed
Rust / compile (push) Has been cancelled
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled
This commit is contained in:
parent
dd650b88f3
commit
c1648e79fe
9 changed files with 239 additions and 13 deletions
|
@ -5332,6 +5332,44 @@ fn parse_at_time_zone() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_interval_data_type() {
|
||||
pg_and_generic().verified_stmt("CREATE TABLE t (i INTERVAL)");
|
||||
for p in 0..=6 {
|
||||
pg_and_generic().verified_stmt(&format!("CREATE TABLE t (i INTERVAL({p}))"));
|
||||
pg_and_generic().verified_stmt(&format!("SELECT '1 second'::INTERVAL({p})"));
|
||||
pg_and_generic().verified_stmt(&format!("SELECT CAST('1 second' AS INTERVAL({p}))"));
|
||||
}
|
||||
let fields = [
|
||||
"YEAR",
|
||||
"MONTH",
|
||||
"DAY",
|
||||
"HOUR",
|
||||
"MINUTE",
|
||||
"SECOND",
|
||||
"YEAR TO MONTH",
|
||||
"DAY TO HOUR",
|
||||
"DAY TO MINUTE",
|
||||
"DAY TO SECOND",
|
||||
"HOUR TO MINUTE",
|
||||
"HOUR TO SECOND",
|
||||
"MINUTE TO SECOND",
|
||||
];
|
||||
for field in fields {
|
||||
pg_and_generic().verified_stmt(&format!("CREATE TABLE t (i INTERVAL {field})"));
|
||||
pg_and_generic().verified_stmt(&format!("SELECT '1 second'::INTERVAL {field}"));
|
||||
pg_and_generic().verified_stmt(&format!("SELECT CAST('1 second' AS INTERVAL {field})"));
|
||||
}
|
||||
for p in 0..=6 {
|
||||
for field in fields {
|
||||
pg_and_generic().verified_stmt(&format!("CREATE TABLE t (i INTERVAL {field}({p}))"));
|
||||
pg_and_generic().verified_stmt(&format!("SELECT '1 second'::INTERVAL {field}({p})"));
|
||||
pg_and_generic()
|
||||
.verified_stmt(&format!("SELECT CAST('1 second' AS INTERVAL {field}({p}))"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_create_table_with_options() {
|
||||
let sql = "CREATE TABLE t (c INT) WITH (foo = 'bar', a = 123)";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue