Skip to content

Commit 38d49e0

Browse files
committed
bigquery: PRIMARY KEY NOT ENFORCED
1 parent 0886b20 commit 38d49e0

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

src/ast/ddl.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ pub enum ConstraintProperty {
806806
NoValidate,
807807
Rely,
808808
NoRely,
809+
NotEnforced,
809810
}
810811

811812
impl fmt::Display for ConstraintProperty {
@@ -815,6 +816,7 @@ impl fmt::Display for ConstraintProperty {
815816
ConstraintProperty::NoValidate => "NOVALIDATE",
816817
ConstraintProperty::Rely => "RELY",
817818
ConstraintProperty::NoRely => "NORELY",
819+
ConstraintProperty::NotEnforced => "NOT ENFORCED",
818820
})
819821
}
820822
}

src/keywords.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ define_keywords!(
243243
ENDPOINT,
244244
END_FRAME,
245245
END_PARTITION,
246+
ENFORCED,
246247
ENGINE,
247248
ENUM,
248249
EPOCH,

src/parser/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,6 +4487,15 @@ impl<'a> Parser<'a> {
44874487
}
44884488
}
44894489
}
4490+
if dialect_of!(self is BigQueryDialect) {
4491+
loop {
4492+
if self.parse_keywords(&[Keyword::NOT, Keyword::ENFORCED]) {
4493+
constraint_properties.push(ConstraintProperty::NotEnforced)
4494+
} else {
4495+
break;
4496+
}
4497+
}
4498+
}
44904499
Ok(constraint_properties)
44914500
}
44924501

tests/sqlparser_bigquery.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,3 +1371,10 @@ fn test_create_table_cluster_by() {
13711371
"CREATE TABLE `myproject`.`mydataset`.`mytable` (service_id STRING, account_id STRING, state STRING, valid_from TIMESTAMP, valid_to TIMESTAMP) PARTITION BY TIMESTAMP_TRUNC(valid_from, MONTH) CLUSTER BY (account_id, state) OPTIONS (description = \"State of an service at a point in time\")"
13721372
);
13731373
}
1374+
1375+
#[test]
1376+
fn test_create_table_primary_key_not_enforced() {
1377+
bigquery().verified_stmt(
1378+
"CREATE TABLE `myproject`.`mydataset`.`mytable` (id INT64, PRIMARY KEY (id) NOT ENFORCED)",
1379+
);
1380+
}

0 commit comments

Comments
 (0)