Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE again #44

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion deploy/samples/subscriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@ apiVersion: hoptimator.linkedin.com/v1alpha1
kind: Subscription
metadata:
name: products
spec:
sql: SELECT "quantity", "product_id" AS KEY FROM INVENTORY."products_on_hand"
database: RAWKAFKA

---

apiVersion: hoptimator.linkedin.com/v1alpha1
kind: Subscription
metadata:
name: products-with-hints
spec:
sql: SELECT "quantity", "product_id" AS KEY FROM INVENTORY."products_on_hand"
database: RAWKAFKA
hints:
numPartitions: "2"
kafka.numPartitions: "7"

3 changes: 3 additions & 0 deletions etc/integration-tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ SELECT * FROM INVENTORY."products_on_hand" LIMIT 1;
-- MySQL CDC -> Kafka
SELECT * FROM RAWKAFKA."products" LIMIT 1;

-- Same, but with hints:
SELECT * FROM RAWKAFKA."products-with-hints" LIMIT 1;

-- test insert into command
!insert into RAWKAFKA."test-sink" SELECT AGE AS PAYLOAD, NAME AS KEY FROM DATAGEN.PERSON
SELECT * FROM RAWKAFKA."test-sink" LIMIT 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
namespace: {{pipeline.namespace}}
spec:
topicName: {{topicName}}
numPartitions: {{numPartitions:null}}
numPartitions: {{kafka.numPartitions:null}}
clientOverrides:
{{clientOverrides}}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Result reconcile(Request request) {

// For sink resources, also expose hints.
Resource.TemplateFactory sinkTemplateFactory = new Resource.SimpleTemplateFactory(subEnv
.orElse(new Resource.SimpleEnvironment(object.getSpec().getHints())));
.orElse(new Resource.SimpleEnvironment(map(object.getSpec().getHints()))));

// Render resources related to all source tables.
List<String> upstreamResources = pipeline.upstreamResources().stream()
Expand Down Expand Up @@ -284,5 +284,13 @@ public static Controller controller(Operator operator, HoptimatorPlanner.Factory
.watch(x -> ControllerBuilder.controllerWatchBuilder(V1alpha1Subscription.class, x).build())
.build();
}

private static Map<String, String> map(Map<String, String> m) {
if (m == null) {
return Collections.emptyMap();
} else {
return m;
}
}
}