Skip to content

Commit 0575519

Browse files
Merge remote-tracking branch 'origin/master' into upsert_sqlite
# Conflicts: # src/main/java/net/sf/jsqlparser/statement/drop/Drop.java # src/main/java/net/sf/jsqlparser/util/deparser/DropDeParser.java
2 parents 2162f3c + 1af682d commit 0575519

4 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/main/java/net/sf/jsqlparser/statement/drop/Drop.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Drop implements Statement {
2828
private List<String> parameters;
2929
private Map<String, List<String>> typeToParameters = new HashMap<>();
3030
private boolean ifExists = false;
31+
private boolean materialized = false;
3132

3233
private boolean isUsingTemporary;
3334

@@ -81,6 +82,14 @@ public Drop withUsingTemporary(boolean useTemporary) {
8182
return this;
8283
}
8384

85+
public boolean isMaterialized() {
86+
return materialized;
87+
}
88+
89+
public void setMaterialized(boolean materialized) {
90+
this.materialized = materialized;
91+
}
92+
8493
public Map<String, List<String>> getTypeToParameters() {
8594
return typeToParameters;
8695
}
@@ -91,7 +100,10 @@ public void setTypeToParameters(Map<String, List<String>> typeToParameters) {
91100

92101
@Override
93102
public String toString() {
94-
String sql = "DROP " + ( isUsingTemporary? "TEMPORARY " : "") + type + " "
103+
String sql = "DROP "
104+
+ (isUsingTemporary ? "TEMPORARY " : "")
105+
+ (materialized ? "MATERIALIZED " : "")
106+
+ type + " "
95107
+ (ifExists ? "IF EXISTS " : "") + name.toString();
96108

97109
if (type.equals("FUNCTION")) {
@@ -121,6 +133,11 @@ public Drop withIfExists(boolean ifExists) {
121133
return this;
122134
}
123135

136+
public Drop withMaterialized(boolean materialized) {
137+
this.setMaterialized(materialized);
138+
return this;
139+
}
140+
124141
public Drop withType(String type) {
125142
this.setType(type);
126143
return this;

src/main/java/net/sf/jsqlparser/util/deparser/DropDeParser.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public void deParse(Drop drop) {
2424
if (drop.isUsingTemporary()) {
2525
buffer.append("TEMPORARY ");
2626
}
27+
if (drop.isMaterialized()) {
28+
buffer.append("MATERIALIZED ");
29+
}
2730
buffer.append(drop.getType());
2831
if (drop.isIfExists()) {
2932
buffer.append(" IF EXISTS");

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5758,6 +5758,7 @@ Drop Drop():
57585758
}
57595759
{
57605760
<K_DROP>
5761+
[ <K_MATERIALIZED> { drop.setMaterialized(true);} ]
57615762
(
57625763
tk=<S_IDENTIFIER>
57635764
|

src/test/java/net/sf/jsqlparser/statement/drop/DropTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ public void testDropViewIssue545_2() throws JSQLParserException {
8787
assertSqlCanBeParsedAndDeparsed("DROP VIEW IF EXISTS myview");
8888
}
8989

90+
@Test
91+
public void testDropMaterializedView() throws JSQLParserException {
92+
assertSqlCanBeParsedAndDeparsed("DROP MATERIALIZED VIEW myview");
93+
}
94+
9095
@Test
9196
public void testDropSchemaIssue855() throws JSQLParserException {
9297
assertSqlCanBeParsedAndDeparsed("DROP SCHEMA myschema");

0 commit comments

Comments
 (0)