-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flink SQL splitting tutorial (#1618)
* feat: Flink SQL splitting tutorial * chore: fix typos in Flink SQL tutorials * fix failing Flink SQL splitting test
- Loading branch information
1 parent
01be037
commit 72d71ec
Showing
78 changed files
with
1,224 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
dev: | ||
steps: | ||
- title: Prerequisites | ||
content: | ||
- action: skip | ||
render: | ||
file: shared/markup/dev/docker-prerequisite.adoc | ||
|
||
- title: Initialize the project | ||
content: | ||
- action: execute | ||
file: tutorial-steps/dev/init.sh | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/init.adoc | ||
|
||
- title: Get Confluent Platform | ||
content: | ||
- action: make_file | ||
file: docker-compose.yml | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/make-docker-compose.adoc | ||
|
||
- action: execute_async | ||
file: tutorial-steps/dev/docker-compose-up.sh | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/start-compose.adoc | ||
|
||
- action: execute | ||
file: tutorial-steps/dev/wait-for-containers.sh | ||
render: | ||
skip: true | ||
|
||
- title: Write the program interactively using the CLI | ||
content: | ||
- action: docker_flinksql_cli_session | ||
container: flink-sql-client | ||
docker_bootup_file: tutorial-steps/dev/start-cli.sh | ||
column_width: 20 | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/start-cli.adoc | ||
stdin: | ||
- file: tutorial-steps/dev/create-acting-events.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/create-acting-events.adoc | ||
|
||
- file: tutorial-steps/dev/populate-acting-events.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/populate-acting-events.adoc | ||
|
||
- file: tutorial-steps/dev/transient-query-drama.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/transient-query-drama.adoc | ||
|
||
- file: tutorial-steps/dev/transient-query-other.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/transient-query-other.adoc | ||
|
||
- file: tutorial-steps/dev/create-acting-events-drama.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/create-acting-events-drama.adoc | ||
|
||
- file: tutorial-steps/dev/create-acting-events-fantasy.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/create-acting-events-fantasy.adoc | ||
|
||
- file: tutorial-steps/dev/create-acting-events-other.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/create-acting-events-other.adoc | ||
|
||
stdout: | ||
directory: tutorial-steps/dev/outputs | ||
|
||
- title: Validate output | ||
content: | ||
- action: execute | ||
file: tutorial-steps/dev/validate-acting-events-fantasy.sh | ||
stdout: tutorial-steps/dev/outputs/validate-acting-events-fantasy.log | ||
render: | ||
file: tutorials/splitting/flinksql/markup/dev/validate-acting-events-per-genre.adoc | ||
|
||
test: | ||
steps: | ||
- title: Decide what testing tools to use | ||
content: | ||
- action: skip | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/test-architecture.adoc | ||
|
||
- title: Create the test skeleton | ||
content: | ||
- action: execute | ||
file: tutorial-steps/test/make-test-dirs.sh | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/make-test-dirs.adoc | ||
|
||
- action: make_file | ||
file: build.gradle | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/make-build-gradle.adoc | ||
|
||
- action: execute | ||
file: tutorial-steps/test/gradle-wrapper.sh | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/make-gradle-wrapper.adoc | ||
|
||
- title: Create SQL resources | ||
content: | ||
- action: make_file | ||
file: src/test/resources/create-acting-events.sql.template | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/create-resource-create-acting-events.sql.template.adoc | ||
|
||
- action: make_file | ||
file: src/test/resources/populate-acting-events.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/create-resource-populate-acting-events.sql.adoc | ||
|
||
- action: make_file | ||
file: src/test/resources/create-acting-events-drama.sql.template | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/create-resource-create-acting-events-drama.sql.template.adoc | ||
|
||
- action: make_file | ||
file: src/test/resources/query-acting-events-drama.sql | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/create-resource-query-acting-events-drama.sql.adoc | ||
|
||
- action: make_file | ||
file: src/test/resources/expected-acting-events-drama.txt | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/create-resource-expected-acting-events-drama.txt.adoc | ||
|
||
- title: Write a test | ||
content: | ||
- action: make_file | ||
file: src/test/java/io/confluent/developer/AbstractFlinkKafkaTest.java | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/make-test-base.adoc | ||
|
||
- action: make_file | ||
file: src/test/java/io/confluent/developer/FlinkSqlSplitStreamTest.java | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/make-test.adoc | ||
|
||
- title: Invoke the test | ||
content: | ||
- action: execute | ||
file: tutorial-steps/test/invoke-test.sh | ||
render: | ||
file: tutorials/splitting/flinksql/markup/test/invoke-test.adoc | ||
|
||
ccloud: | ||
steps: | ||
- title: Run your app to Confluent Cloud | ||
content: | ||
- action: skip | ||
render: | ||
file: shared/markup/ccloud/try-ccloud.adoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...utorials/aggregating-count/flinksql/markup/dev/create-movie-sales-by-title.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Since the output of our transient query looks right, the next step is to make the query persistent. This looks exactly like the transient query, except we first create a new table with the https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/connectors/table/upsert-kafka/[Upsert Kafka] connector and then `INSERT INTO` the table. We use the Upsert Kafka connector because we only care about the most recent aggregate for a given title (the key column). The `INSERT INTO` statement returns to the CLI prompt right away, having created a persistent stream processing program running in the Flink cluster, continuously processing input records and updating the resulting `movie_ticket_sales_by_title` table. | ||
|
||
Now go ahead and tun the following two commands in your Flink SQL session: | ||
Now go ahead and run the following two commands in your Flink SQL session: | ||
+++++ | ||
<pre class="snippet"><code class="sql">{% include_raw tutorials/aggregating-count/flinksql/code/tutorial-steps/dev/create-movie-sales-by-title.sql %}</code></pre> | ||
+++++ |
2 changes: 1 addition & 1 deletion
2
.../tutorials/aggregating-count/flinksql/markup/dev/create-movie-ticket-sales.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...udes/tutorials/aggregating-count/ksql/markup/dev/create-movie-ticket-sales.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...utorials/aggregating-minmax/flinksql/markup/dev/create-movie-sales-by-year.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Since the output of our transient query looks right, the next step is to make the query persistent. This looks exactly like the transient query, except we first create a new table with the https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/connectors/table/upsert-kafka/[Upsert Kafka] connector and then `INSERT INTO` the table. We use the Upsert Kafka connector because we only care about the most recent aggregates for a given release year (the key column). The `INSERT INTO` statement returns to the CLI prompt right away, having created a persistent stream processing program running in the Flink cluster, continuously processing input records and updating the resulting `movie_sales_by_year` table. | ||
|
||
Now go ahead and tun the following two commands in your Flink SQL session: | ||
Now go ahead and run the following two commands in your Flink SQL session: | ||
+++++ | ||
<pre class="snippet"><code class="sql">{% include_raw tutorials/aggregating-minmax/flinksql/code/tutorial-steps/dev/create-movie-sales-by-year.sql %}</code></pre> | ||
+++++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ls/joining-stream-stream/flinksql/markup/dev/populate-shipped-orders-table.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tutorial-steps/dev/outputs/ | ||
|
||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
STEPS_DIR := tutorial-steps | ||
DEV_OUTPUTS_DIR := $(STEPS_DIR)/dev/outputs | ||
TEMP_DIR := $(shell mktemp -d) | ||
SEQUENCE := "dev, test, ccloud" | ||
|
||
tutorial: | ||
rm -r $(DEV_OUTPUTS_DIR) || true | ||
mkdir $(DEV_OUTPUTS_DIR) | ||
harness-runner ../../../../../_data/harnesses/splitting/flinksql.yml $(TEMP_DIR) $(SEQUENCE) | ||
diff --strip-trailing-cr $(STEPS_DIR)/dev/expected-acting-events-fantasy.log $(DEV_OUTPUTS_DIR)/validate-acting-events-fantasy.log | ||
reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
} | ||
|
||
plugins { | ||
id "java" | ||
} | ||
|
||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
version = "0.0.1" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation "com.google.guava:guava:31.1-jre" | ||
testImplementation "junit:junit:4.13.2" | ||
testImplementation 'org.testcontainers:testcontainers:1.17.6' | ||
testImplementation 'org.testcontainers:kafka:1.17.6' | ||
testImplementation "org.apache.flink:flink-sql-connector-kafka:1.16.1" | ||
testImplementation "org.apache.flink:flink-sql-avro-confluent-registry:1.16.1" | ||
testImplementation "org.apache.flink:flink-test-utils:1.16.1" | ||
testImplementation "org.apache.flink:flink-test-utils-junit:1.16.1" | ||
testImplementation "org.apache.flink:flink-table-api-java-bridge:1.16.1" | ||
testImplementation "org.apache.flink:flink-table-planner_2.12:1.16.1" | ||
testImplementation "org.apache.flink:flink-table-planner_2.12:1.16.1:tests" | ||
testImplementation "org.apache.flink:flink-statebackend-rocksdb:1.16.1" | ||
} |
Oops, something went wrong.