Skip to content

Commit 4941f78

Browse files
feeblefakiejnmtjosh-wong
authored
Backport to branch(3) : Add PartiQL parser (Create Table and Insert) (#191)
Co-authored-by: Jun Nemoto <[email protected]> Co-authored-by: Josh Wong <[email protected]>
1 parent 7fb4269 commit 4941f78

File tree

16 files changed

+921
-0
lines changed

16 files changed

+921
-0
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ subprojects {
4343
googleJavaFormatVersion = '1.7'
4444
dockerPluginVersion = '0.34.0'
4545
bouncyCastleCryptoVersion = '1.70'
46+
partiqlVersion = '1.2.2'
4647

4748
dockerVersion = project.properties['dockerVersion'] ?: project.version
4849
}

common/src/main/java/com/scalar/dl/genericcontracts/table/v1_0_0/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public class Constants {
77
// Metadata
88
public static final String PACKAGE = "table";
99
public static final String VERSION = "v1_0_0";
10+
public static final String CONTRACT_CREATE = PACKAGE + "." + VERSION + ".Create";
11+
public static final String CONTRACT_INSERT = PACKAGE + "." + VERSION + ".Insert";
1012
public static final String CONTRACT_GET_ASSET_ID = PACKAGE + "." + VERSION + ".GetAssetId";
1113
public static final String CONTRACT_SCAN = PACKAGE + "." + VERSION + ".Scan";
1214

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ include 'rpc'
44
include 'client'
55
include 'schema-loader'
66
include 'generic-contracts'
7+
include 'table-store'

table-store/build.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
plugins {
2+
id 'net.ltgt.errorprone' version "${errorpronePluginVersion}"
3+
id "com.github.spotbugs" version "${spotbugsPluginVersion}"
4+
}
5+
6+
dependencies {
7+
implementation project(':client')
8+
implementation project(':generic-contracts')
9+
implementation group: 'org.partiql', name: 'partiql-parser', version: "${partiqlVersion}"
10+
11+
// for Error Prone
12+
errorprone "com.google.errorprone:error_prone_core:${errorproneVersion}"
13+
errorproneJavac "com.google.errorprone:javac:${errorproneJavacVersion}"
14+
15+
// for SpotBugs
16+
spotbugs "com.github.spotbugs:spotbugs:${spotbugsVersion}"
17+
compileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}"
18+
testCompileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}"
19+
}
20+
21+
spotless {
22+
java {
23+
target 'src/*/java/**/*.java'
24+
importOrder()
25+
removeUnusedImports()
26+
googleJavaFormat('1.7')
27+
}
28+
}
29+
30+
spotbugs {
31+
ignoreFailures = false
32+
showStackTraces = true
33+
showProgress = true
34+
effort = 'default'
35+
reportLevel = 'default'
36+
maxHeapSize = '1g'
37+
extraArgs = [ '-nested:false' ]
38+
jvmArgs = [ '-Duser.language=en' ]
39+
}
40+
41+
spotbugsMain.reports {
42+
html.enabled = true
43+
}
44+
45+
spotbugsTest.reports {
46+
html.enabled = true
47+
}
48+
49+
task sourcesJar(type: Jar) {
50+
classifier = 'sources'
51+
from sourceSets.main.allSource
52+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package com.scalar.dl.tablestore.client.error;
2+
3+
import com.scalar.dl.ledger.error.ScalarDlError;
4+
import com.scalar.dl.ledger.service.StatusCode;
5+
6+
public enum TableStoreClientError implements ScalarDlError {
7+
8+
//
9+
// Errors for INVALID_ARGUMENT(414)
10+
//
11+
SYNTAX_ERROR_IN_PARTIQL_PARSER(
12+
StatusCode.INVALID_ARGUMENT,
13+
"001",
14+
"Syntax error. Line=%d, Offset=%d, Length=%d, Code=%s",
15+
"",
16+
""),
17+
SYNTAX_ERROR_INVALID_PRIMARY_KEY_SPECIFICATION(
18+
StatusCode.INVALID_ARGUMENT,
19+
"002",
20+
"Syntax error. The primary key column must be specified only once in a table.",
21+
"",
22+
""),
23+
SYNTAX_ERROR_INVALID_COLUMN_CONSTRAINTS(
24+
StatusCode.INVALID_ARGUMENT,
25+
"003",
26+
"Syntax error. The specified column constraint is invalid.",
27+
"",
28+
""),
29+
SYNTAX_ERROR_INVALID_DATA_TYPE(
30+
StatusCode.INVALID_ARGUMENT,
31+
"004",
32+
"Syntax error. The specified data type is invalid.",
33+
"",
34+
""),
35+
SYNTAX_ERROR_INVALID_INSERT_STATEMENT(
36+
StatusCode.INVALID_ARGUMENT,
37+
"005",
38+
"Syntax error. The specified insert statement is invalid.",
39+
"",
40+
""),
41+
SYNTAX_ERROR_INVALID_STATEMENT(
42+
StatusCode.INVALID_ARGUMENT,
43+
"006",
44+
"Syntax error. The specified statement is invalid.",
45+
"",
46+
""),
47+
SYNTAX_ERROR_INVALID_EXPRESSION(
48+
StatusCode.INVALID_ARGUMENT,
49+
"007",
50+
"Syntax error. The specified expression is invalid. Expression: %s",
51+
"",
52+
""),
53+
SYNTAX_ERROR_INVALID_LITERAL(
54+
StatusCode.INVALID_ARGUMENT,
55+
"008",
56+
"Syntax error. The specified literal is invalid. Literal: %s",
57+
"",
58+
""),
59+
;
60+
61+
private static final String COMPONENT_NAME = "DL-TABLE-STORE";
62+
63+
private final StatusCode statusCode;
64+
private final String id;
65+
private final String message;
66+
private final String cause;
67+
private final String solution;
68+
69+
TableStoreClientError(
70+
StatusCode statusCode, String id, String message, String cause, String solution) {
71+
validate(COMPONENT_NAME, statusCode, id, message, cause, solution);
72+
73+
this.statusCode = statusCode;
74+
this.id = id;
75+
this.message = message;
76+
this.cause = cause;
77+
this.solution = solution;
78+
}
79+
80+
@Override
81+
public String getComponentName() {
82+
return COMPONENT_NAME;
83+
}
84+
85+
@Override
86+
public StatusCode getStatusCode() {
87+
return statusCode;
88+
}
89+
90+
@Override
91+
public String getId() {
92+
return id;
93+
}
94+
95+
@Override
96+
public String getMessage() {
97+
return message;
98+
}
99+
100+
@Override
101+
public String getCause() {
102+
return cause;
103+
}
104+
105+
@Override
106+
public String getSolution() {
107+
return solution;
108+
}
109+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.scalar.dl.tablestore.client.partiql;
2+
3+
public enum DataType {
4+
BOOLEAN,
5+
NUMBER,
6+
STRING,
7+
}

0 commit comments

Comments
 (0)