Skip to content

Commit ac4bbb9

Browse files
Added Support for Quoted Keys and JobProperties in CREATE TRIGGER (#200)
* Added Support for Quoted Keys and JobProperties in CREATE TRIGGER * Makefile Changes * Fix Tests * Fix Another Test --------- Co-authored-by: Shrinand Thakkar <sthakkar@linkedin.com>
1 parent 66eb61d commit ac4bbb9

9 files changed

Lines changed: 1078 additions & 581 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ quickstart: build deploy
4141
deploy-demo: deploy
4242
kubectl apply -f ./deploy/samples/demodb.yaml
4343
kubectl apply -f ./deploy/samples/tabletriggers.yaml
44+
kubectl apply -f ./deploy/samples/retl-job-template.yaml
4445
kubectl apply -f ./deploy/samples/crontrigger.yaml
4546
kubectl apply -f ./deploy/samples/user-jobs.yaml
4647

4748
undeploy-demo: undeploy
4849
kubectl delete -f ./deploy/samples/demodb.yaml || echo "skipping"
4950
kubectl delete -f ./deploy/samples/tabletriggers.yaml || echo "skipping"
51+
kubectl delete -f ./deploy/samples/retl-job-template.yaml || echo "skipping"
5052
kubectl delete -f ./deploy/samples/crontrigger.yaml || echo "skipping"
5153

5254
deploy-flink: deploy
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: hoptimator.linkedin.com/v1alpha1
2+
kind: JobTemplate
3+
metadata:
4+
name: retl-job-template
5+
namespace: default
6+
spec:
7+
yaml: |
8+
apiVersion: batch/v1
9+
kind: Job
10+
metadata:
11+
name: {{name}}-job
12+
spec:
13+
template:
14+
spec:
15+
containers:
16+
- name: hello
17+
image: alpine/k8s:1.33.0
18+
env:
19+
- name: TABLE_TRIGGER_NAME
20+
value: "{{name}}-trigger"
21+
- name: SOURCE_TABLE_NAME
22+
value: "{{offline.table.name}}"
23+
- name: ONLINE_TABLE_NAME
24+
value: "{{job.properties.online.table.name}}"
25+
command: ["bash", "-c", "echo {{name}}-trigger fired at `date`"]
26+
restartPolicy: Never
27+
backoffLimit: 4

hoptimator-jdbc/src/main/codegen/includes/parserImpls.ftl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,20 @@ SqlNodeList Options() :
5454

5555
void Option(List<SqlNode> list) :
5656
{
57-
final SqlIdentifier id;
57+
final SqlNode key;
5858
final SqlNode value;
5959
}
6060
{
61-
id = SimpleIdentifier()
61+
(
62+
key = CompoundIdentifier()
63+
|
64+
<QUOTED_STRING> {
65+
key = SqlLiteral.createCharString(
66+
SqlParserUtil.parseString(token.image), getPos());
67+
}
68+
)
6269
value = Literal() {
63-
list.add(id);
70+
list.add(key);
6471
list.add(value);
6572
}
6673
}

hoptimator-jdbc/src/main/java/com/linkedin/hoptimator/jdbc/HoptimatorDdlUtils.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,15 @@ static Map<String, String> options(SqlNodeList optionList) {
173173
Map<String, String> options = new HashMap<>();
174174
if (optionList != null) {
175175
for (int i = 0; i < optionList.size() - 1; i += 2) {
176-
SqlIdentifier k = (SqlIdentifier) optionList.get(i);
176+
SqlNode k = optionList.get(i);
177177
SqlLiteral v = (SqlLiteral) optionList.get(i + 1);
178-
options.put(k.getSimple(), v.getValueAs(String.class));
178+
String keyStr;
179+
if (k instanceof SqlIdentifier) {
180+
keyStr = String.join(".", ((SqlIdentifier) k).names);
181+
} else {
182+
keyStr = ((SqlLiteral) k).getValueAs(String.class);
183+
}
184+
options.put(keyStr, v.getValueAs(String.class));
179185
}
180186
}
181187
return options;

0 commit comments

Comments
 (0)