Skip to content

Commit 7460762

Browse files
ssteinhauserStefan Steinhausermanticore-projects
authored
Exasol: IMPORT/EXPORT (#2256)
* feat: Implement IMPORT statement grammar For reference see https://docs.exasol.com/db/latest/sql/import.htm * feat: Classify new keywords in ParserKeywordsUtils * feat: Implement java classes for IMPORT statement * feat: Add LOOKAHEADs for IMPORT statement * fix: Fix issues in IMPORT implementation * feat: Update keywords * feat: Allow IMPORT as FromItem in SELECT * fix: Split double dot to fix broken unit tests * fix: Fix errors occured during verify step * test: Implement unit tests for IMPORT * feat: Simplify grammar * test: Implement test for sub IMPORT * fix: Use double dot token in IMPORT * feat: Implement EXPORT statement Implement Exasol EXPORT statement (see https://docs.exasol.com/db/latest/sql/export.htm) * refactor: Fix file extension in IMPORT tests * test: Implement unit tests for EXPORT statement * feat: Implement classes for EXPORT statement * test: Fix EXPORT unit tests * fix: Implement missing SampleClause methods * feat: Add further Import tests * fix: Update Keywords and fix boolean data type matching * fix: Fix SourceDestinationType implementations * style: Run spotlessApply * fix: Fix spotbugsMain * feat: Add test for RTRIM and LTRIM functions Refs: #2256 * feat: Add EXPORT feature flag * feat: Implement EXASOL dialect feature flag --------- Co-authored-by: Stefan Steinhauser <[email protected]> Co-authored-by: manticore-projects <[email protected]>
1 parent abca809 commit 7460762

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3552
-9
lines changed

src/main/java/module-info.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
exports net.sf.jsqlparser.statement.delete;
3737
exports net.sf.jsqlparser.statement.drop;
3838
exports net.sf.jsqlparser.statement.execute;
39+
exports net.sf.jsqlparser.statement.export;
3940
exports net.sf.jsqlparser.statement.grant;
41+
exports net.sf.jsqlparser.statement.imprt;
4042
exports net.sf.jsqlparser.statement.insert;
4143
exports net.sf.jsqlparser.statement.merge;
4244
exports net.sf.jsqlparser.statement.piped;

src/main/java/net/sf/jsqlparser/parser/ParserKeywordsUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class ParserKeywordsUtils {
5656
{"CHECK", RESTRICTED_SQL2016},
5757
{"CONNECT", RESTRICTED_ALIAS},
5858
{"CONNECT_BY_ROOT", RESTRICTED_JSQLPARSER},
59+
{"CSV", RESTRICTED_JSQLPARSER},
5960
{"PRIOR", RESTRICTED_JSQLPARSER},
6061
{"CONSTRAINT", RESTRICTED_SQL2016},
6162
{"CREATE", RESTRICTED_ALIAS},
@@ -66,12 +67,15 @@ public class ParserKeywordsUtils {
6667
{"DISTINCTROW", RESTRICTED_SQL2016},
6768
{"DOUBLE", RESTRICTED_ALIAS},
6869
{"ELSE", RESTRICTED_JSQLPARSER},
70+
{"ERRORS", RESTRICTED_JSQLPARSER},
6971
{"EXCEPT", RESTRICTED_SQL2016},
7072
{"EXCLUDES", RESTRICTED_JSQLPARSER},
7173
{"EXISTS", RESTRICTED_SQL2016},
7274
{"EXTEND", RESTRICTED_JSQLPARSER},
7375
{"FALSE", RESTRICTED_SQL2016},
76+
{"FBV", RESTRICTED_JSQLPARSER},
7477
{"FETCH", RESTRICTED_SQL2016},
78+
{"FILE", RESTRICTED_JSQLPARSER},
7579
{"FINAL", RESTRICTED_JSQLPARSER},
7680
{"FOR", RESTRICTED_SQL2016},
7781
{"FORCE", RESTRICTED_SQL2016},
@@ -87,6 +91,7 @@ public class ParserKeywordsUtils {
8791
{"IIF", RESTRICTED_ALIAS},
8892
{"IGNORE", RESTRICTED_ALIAS},
8993
{"ILIKE", RESTRICTED_SQL2016},
94+
{"IMPORT", RESTRICTED_JSQLPARSER},
9095
{"IN", RESTRICTED_SQL2016},
9196
{"INCLUDES", RESTRICTED_JSQLPARSER},
9297
{"INNER", RESTRICTED_SQL2016},
@@ -122,12 +127,14 @@ public class ParserKeywordsUtils {
122127
{"RETURNING", RESTRICTED_JSQLPARSER},
123128
{"RIGHT", RESTRICTED_SQL2016},
124129
{"SAMPLE", RESTRICTED_ALIAS},
130+
{"SCRIPT", RESTRICTED_JSQLPARSER},
125131
{"SEL", RESTRICTED_ALIAS},
126132
{"SELECT", RESTRICTED_ALIAS},
127133
{"SEMI", RESTRICTED_JSQLPARSER},
128134
{"SET", RESTRICTED_JSQLPARSER},
129135
{"SOME", RESTRICTED_JSQLPARSER},
130136
{"START", RESTRICTED_JSQLPARSER},
137+
{"STATEMENT", RESTRICTED_JSQLPARSER},
131138
{"TABLES", RESTRICTED_ALIAS},
132139
{"TOP", RESTRICTED_SQL2016},
133140
{"TRAILING", RESTRICTED_SQL2016},
@@ -147,6 +154,7 @@ public class ParserKeywordsUtils {
147154
{"VALUE", RESTRICTED_JSQLPARSER},
148155
{"VALUES", RESTRICTED_SQL2016},
149156
{"VARYING", RESTRICTED_JSQLPARSER},
157+
{"VERIFY", RESTRICTED_JSQLPARSER},
150158
{"WHEN", RESTRICTED_SQL2016},
151159
{"WHERE", RESTRICTED_SQL2016},
152160
{"WINDOW", RESTRICTED_SQL2016},

src/main/java/net/sf/jsqlparser/parser/feature/Feature.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,18 @@ public enum Feature {
798798
*/
799799
allowedNestingDepth(10),
800800

801-
dialect(null);
801+
dialect(null),
802+
803+
/**
804+
* "IMPORT"
805+
*/
806+
imprt,
807+
808+
/**
809+
* "EXPORT"
810+
*/
811+
export,
812+
;
802813

803814
private final Object value;
804815
private final boolean configurable;

src/main/java/net/sf/jsqlparser/schema/Table.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.sf.jsqlparser.expression.MySQLIndexHint;
1818
import net.sf.jsqlparser.expression.SQLServerHints;
1919
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
20+
import net.sf.jsqlparser.statement.ErrorDestination;
2021
import net.sf.jsqlparser.statement.select.FromItem;
2122
import net.sf.jsqlparser.statement.select.FromItemVisitor;
2223
import net.sf.jsqlparser.statement.select.IntoTableVisitor;
@@ -27,7 +28,7 @@
2728
/**
2829
* A table. It can have an alias and the schema name it belongs to.
2930
*/
30-
public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName {
31+
public class Table extends ASTNodeAccessImpl implements ErrorDestination, FromItem, MultiPartName {
3132

3233
// private Database database;
3334
// private String schemaName;
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
public class CSVColumn {
15+
private Long startIndex;
16+
private Long endIndex;
17+
private StringValue format;
18+
private String delimit;
19+
20+
public CSVColumn(Long startIndex, Long endIndex) {
21+
this.startIndex = startIndex;
22+
this.endIndex = endIndex;
23+
}
24+
25+
public CSVColumn(Long index) {
26+
this(index, null);
27+
}
28+
29+
public Long getStartIndex() {
30+
return startIndex;
31+
}
32+
33+
public void setStartIndex(Long startIndex) {
34+
this.startIndex = startIndex;
35+
}
36+
37+
public Long getIndex() {
38+
return getStartIndex();
39+
}
40+
41+
public void setIndex(Long index) {
42+
setStartIndex(index);
43+
}
44+
45+
public Long getEndIndex() {
46+
return endIndex;
47+
}
48+
49+
public void setEndIndex(Long endIndex) {
50+
this.endIndex = endIndex;
51+
}
52+
53+
public StringValue getFormat() {
54+
return format;
55+
}
56+
57+
public void setFormat(StringValue format) {
58+
this.format = format;
59+
}
60+
61+
public String getDelimit() {
62+
return delimit;
63+
}
64+
65+
public void setDelimit(String delimit) {
66+
this.delimit = delimit;
67+
}
68+
69+
@Override
70+
public String toString() {
71+
StringBuilder sql = new StringBuilder();
72+
73+
sql.append(startIndex);
74+
if (endIndex != null) {
75+
sql.append(" .. ");
76+
sql.append(endIndex);
77+
} else if (format != null || delimit != null) {
78+
if (format != null) {
79+
sql.append(" FORMAT = ");
80+
sql.append(format);
81+
}
82+
83+
if (delimit != null) {
84+
sql.append(" DELIMIT = ");
85+
sql.append(delimit);
86+
}
87+
}
88+
89+
return sql.toString();
90+
}
91+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
public class CSVFileDestination implements ErrorDestination {
15+
private ConnectionDefinition connectionDefinition;
16+
private boolean local;
17+
private boolean secure;
18+
private StringValue file;
19+
20+
public ConnectionDefinition getConnectionDefinition() {
21+
return connectionDefinition;
22+
}
23+
24+
public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
25+
this.connectionDefinition = connectionDefinition;
26+
}
27+
28+
public boolean isLocal() {
29+
return local;
30+
}
31+
32+
public void setLocal(boolean local) {
33+
this.local = local;
34+
}
35+
36+
public boolean isSecure() {
37+
return secure;
38+
}
39+
40+
public void setSecure(boolean secure) {
41+
this.secure = secure;
42+
}
43+
44+
public StringValue getFile() {
45+
return file;
46+
}
47+
48+
public void setFile(StringValue file) {
49+
this.file = file;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
StringBuilder sql = new StringBuilder();
55+
56+
if (local) {
57+
sql.append("LOCAL ");
58+
if (secure) {
59+
sql.append("SECURE ");
60+
}
61+
}
62+
63+
sql.append("CSV");
64+
65+
if (connectionDefinition != null) {
66+
sql.append(" ");
67+
sql.append(connectionDefinition);
68+
}
69+
70+
sql.append(" FILE ");
71+
sql.append(file);
72+
73+
return sql.toString();
74+
}
75+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2025 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
import java.io.Serializable;
15+
16+
public class CertificateVerification implements Serializable {
17+
private Boolean ignoreCertificate;
18+
private StringValue publicKey;
19+
20+
public StringValue getPublicKey() {
21+
return publicKey;
22+
}
23+
24+
public void setPublicKey(StringValue publicKey) {
25+
this.publicKey = publicKey;
26+
}
27+
28+
public Boolean getIgnoreCertificate() {
29+
return ignoreCertificate;
30+
}
31+
32+
public void setIgnoreCertificate(Boolean ignoreCertificate) {
33+
this.ignoreCertificate = ignoreCertificate;
34+
}
35+
36+
public Boolean getVerifyCertificate() {
37+
return !ignoreCertificate;
38+
}
39+
40+
public void setVerifyCertificate(Boolean verifyCertificate) {
41+
this.ignoreCertificate = !verifyCertificate;
42+
}
43+
44+
@Override
45+
public String toString() {
46+
StringBuilder sql = new StringBuilder();
47+
48+
if (ignoreCertificate != null) {
49+
if (ignoreCertificate) {
50+
sql.append("IGNORE ");
51+
} else {
52+
sql.append("VERIFY ");
53+
}
54+
sql.append("CERTIFICATE");
55+
}
56+
57+
if (publicKey != null) {
58+
if (ignoreCertificate != null) {
59+
sql.append(" ");
60+
}
61+
sql.append("PUBLIC KEY ");
62+
sql.append(publicKey);
63+
}
64+
65+
return sql.toString();
66+
}
67+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
public class CloudConnectionDefinition extends ConnectionDefinition {
13+
private String storage;
14+
15+
public String getStorage() {
16+
return storage;
17+
}
18+
19+
public void setStorage(String storage) {
20+
this.storage = storage;
21+
}
22+
23+
@Override
24+
public void setCertificateVerification(CertificateVerification certificateVerification) {}
25+
26+
@Override
27+
public String toString() {
28+
StringBuilder sql = new StringBuilder();
29+
30+
sql.append("AT CLOUD ");
31+
sql.append(storage);
32+
sql.append(" ");
33+
appendConnectionDefinition(sql);
34+
35+
return sql.toString();
36+
}
37+
}

0 commit comments

Comments
 (0)