Skip to content

Commit d617d4d

Browse files
authored
Fix multiple owner references (#1)
* Fix multiple owner references * Add additional printer columns to subscription CRD
1 parent 1a86043 commit d617d4d

28 files changed

+122
-92
lines changed

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
2+
bounce: build undeploy deploy
33

44
build:
55
./gradlew build
@@ -15,6 +15,9 @@ integration-tests:
1515
clean:
1616
./gradlew clean
1717

18+
undeploy:
19+
kubectl delete -f ./deploy || echo "skipping"
20+
1821
quickstart: build deploy-dev-environment deploy
1922

2023
deploy-dev-environment:
@@ -29,13 +32,13 @@ deploy-dev-environment:
2932
deploy:
3033
kubectl apply -f ./deploy/
3134

32-
undeploy:
33-
kubectl delete -f ./deploy || echo "skipping"
34-
3535
deploy-samples:
3636
kubectl apply -f ./deploy/samples
3737

3838
release:
3939
./gradlew publish
4040

41-
.PHONY: build clean quickstart deploy-dev-environment deploy deploy-samples integration-tests
41+
generate-models:
42+
./models/generate-models.sh
43+
44+
.PHONY: build clean quickstart deploy-dev-environment deploy deploy-samples integration-tests bounce generate-models

deploy/kafkatopics.crd.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ spec:
3232
description: Desired Kafka topic configuration.
3333
type: object
3434
properties:
35-
name:
35+
topicName:
3636
description: The topic name.
3737
type: string
3838
numPartitions:
@@ -67,7 +67,7 @@ spec:
6767
additionalProperties:
6868
type: string
6969
required:
70-
- name
70+
- topicName
7171
status:
7272
description: Current state of the topic.
7373
type: object

deploy/samples/kafkatopic.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

deploy/samples/subscription.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

deploy/samples/subscriptions.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: hoptimator.linkedin.com/v1alpha1
2+
kind: Subscription
3+
metadata:
4+
name: people
5+
spec:
6+
sql: SELECT NAME FROM DATAGEN.PERSON
7+
database: RAWKAFKA
8+
9+
---
10+
11+
apiVersion: hoptimator.linkedin.com/v1alpha1
12+
kind: Subscription
13+
metadata:
14+
name: companies
15+
spec:
16+
sql: SELECT NAME FROM DATAGEN.COMPANY
17+
database: RAWKAFKA
18+
19+
---
20+
21+
apiVersion: hoptimator.linkedin.com/v1alpha1
22+
kind: Subscription
23+
metadata:
24+
name: names
25+
spec:
26+
sql: SELECT p.PAYLOAD || c.PAYLOAD FROM RAWKAFKA."people" p, RAWKAFKA."companies" c
27+
database: RAWKAFKA
28+
29+

deploy/subscriptions.crd.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,13 @@ spec:
5353
type: string
5454
subresources:
5555
status: {}
56+
additionalPrinterColumns:
57+
- name: DB
58+
type: string
59+
description: The database where the subscription is materialized.
60+
jsonPath: .spec.database
61+
- name: SQL
62+
type: string
63+
description: The SQL query that the subscription materializes.
64+
jsonPath: .spec.sql
65+

hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/AvroConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ public final class AvroConverter {
2121
private AvroConverter() {
2222
}
2323

24-
public static Schema avro(String name, String namespace, RelDataType dataType) {
24+
public static Schema avro(String namespace, String name, RelDataType dataType) {
2525
if (dataType.isStruct()) {
2626
List<Schema.Field> fields = dataType.getFieldList().stream()
2727
.filter(x -> !x.getName().startsWith("__")) // don't write out hidden fields
28-
.map(x -> new Schema.Field(sanitize(x.getName()), avro(x.getName(), namespace, x.getType()), describe(x), null))
28+
.map(x -> new Schema.Field(sanitize(x.getName()), avro(namespace, x.getName(), x.getType()), describe(x), null))
2929
.collect(Collectors.toList());
3030
return Schema.createRecord(sanitize(name), dataType.toString(), namespace, false, fields);
3131
} else {
@@ -49,9 +49,9 @@ public static Schema avro(String name, String namespace, RelDataType dataType) {
4949
}
5050
}
5151

52-
public static Schema avro(String name, String namespace, RelProtoDataType relProtoDataType) {
52+
public static Schema avro(String namespace, String name, RelProtoDataType relProtoDataType) {
5353
RelDataTypeFactory factory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
54-
return avro(name, namespace, relProtoDataType.apply(factory));
54+
return avro(namespace, name, relProtoDataType.apply(factory));
5555
}
5656

5757
private static Schema createAvroTypeWithNullability(Schema.Type rawType, boolean nullable) {

hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/Resource.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ public abstract class Resource {
2828
private final String template;
2929
private final Map<String, Supplier<String>> properties = new HashMap<>();
3030

31-
/** A Resource that will be rendered with the specified template */
32-
public Resource(String name, String template) {
33-
this(template);
34-
export("name", name);
35-
}
36-
3731
/** A Resource that will be rendered with the specified template */
3832
public Resource(String template) {
3933
this.template = template;
@@ -73,10 +67,6 @@ public Set<String> keys() {
7367
return properties.keySet();
7468
}
7569

76-
public String name() {
77-
return getOrDefault("name", () -> "(no name)");
78-
}
79-
8070
/** Render this Resource using the given TemplateFactory */
8171
public String render(TemplateFactory templateFactory) {
8272
return templateFactory.get(this).render(this);
@@ -103,7 +93,7 @@ public String toString() {
10393
public String getOrDefault(String key, Supplier<String> f) {
10494
String computed = properties.getOrDefault(key, f).get();
10595
if (computed == null) {
106-
throw new IllegalArgumentException("Resource '" + name() + "' missing variable '" + key + "'");
96+
throw new IllegalArgumentException("Resource missing variable '" + key + "'");
10797
}
10898
return computed;
10999
}

hoptimator-cli/src/main/java/com/linkedin/hoptimator/HoptimatorCliApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void execute(String line, DispatchCallback dispatchCallback) {
9898
try {
9999
HoptimatorPlanner planner = HoptimatorPlanner.fromModelFile(connectionUrl, new Properties());
100100
RelNode plan = planner.logical(sql);
101-
String avroSchema = AvroConverter.avro("OutputRecord", "OutputNamespace", plan.getRowType()).toString(true);
101+
String avroSchema = AvroConverter.avro("OutputNamespace", "OutputName", plan.getRowType()).toString(true);
102102
sqlline.output(avroSchema);
103103
dispatchCallback.setToSuccess();
104104
} catch (Exception e) {

hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88

99
public class KafkaTopic extends Resource {
1010
public KafkaTopic(String name, Integer numPartitions, Map<String, String> clientOverrides) {
11-
super(name, "KafkaTopic");
11+
super("KafkaTopic");
12+
export("name", name);
1213
export("numPartitions", Optional.ofNullable(numPartitions)
1314
.map(x -> Integer.toString(x)).orElse("null"));
1415
export("clientOverrides", clientOverrides);
1516
}
16-
17-
public KafkaTopic(String name) {
18-
this(name, null, Collections.emptyMap());
19-
}
2017
}
2118

0 commit comments

Comments
 (0)