BlackHole Connector
Overview
The BlackHole connector is a black hole sink that discards all written data and does not generate any output. It is similar to /dev/null in Unix and is used in scenarios where no actual output is required.
| Category | Details |
|---|---|
| Supported type | Result table |
| Running mode | Batch mode and stream mode |
| Data format | Not applicable |
| API type | SQL |
| Whether result table can be updated or deleted | Yes |
Application Scenarios
- Performance test: Tests the throughput of the source and computing layers of Flink SQL jobs, excluding the I/O impact of the sink.
- Logic verification: Verifies whether the SQL syntax and job DAG are correctly constructed. You do not need to care about the output result.
- Development and debugging: Functions as the final sink placeholder in scenarios where only the source or intermediate processing result needs to be observed.
Notes and Constraints
- It can only be used as a sink and cannot be used as a source.
- All written data will be discarded and cannot be restored.
- It is not applicable to data persistence scenarios in the production environment.
Syntax Structure
CREATE TABLE {table_name} (
{column_name} {column_type},
...
) WITH (
'connector' = 'blackhole'
); WITH Parameters
| Parameter | Mandatory | Type | Default Value | Value Range | Description |
|---|---|---|---|---|---|
| connector | Yes | String | None | blackhole | Specifies that the connector type is BlackHole. This parameter is mandatory and must be set to the fixed value blackhole. The Flink runtime loads the corresponding BlackHole SinkFactory based on this value. All written data is directly discarded during runtime, and no I/O operations are generated. |
For the BlackHole connector, you do not need to configure any other parameters except the connector parameter.
Usage Example
- Example 1: Create a BlackHole sink table to discard all written data.
-- Create a DataGen source table. CREATE TABLE datagen_source ( id BIGINT, name STRING, `value` DOUBLE ) WITH ( 'connector' = 'datagen', 'rows-per-second' = '1000', 'fields.id.kind' = 'sequence', 'fields.id.start' = '1', 'fields.id.end' = '100000' ); -- Create the BlackHole result table. CREATE TABLE blackhole_sink ( id BIGINT, name STRING, `value` DOUBLE ) WITH ( 'connector' = 'blackhole' ); -- Submit the job. INSERT INTO blackhole_sink SELECT id, name, `value` FROM datagen_source;
- Example 2: Use DataGen to generate high-throughput data and use the BlackHole sink to receive the data, testing the pure processing capacity of the source and computing layers.
-- Create a DataGen source table (high throughput configuration). CREATE TABLE datagen_source ( id BIGINT, payload STRING, event_time TIMESTAMP(3), WATERMARK FOR event_time AS event_time - INTERVAL '1' SECOND ) WITH ( 'connector' = 'datagen', 'rows-per-second' = '100000', 'fields.id.kind' = 'sequence', 'fields.id.start' = '1', 'fields.id.end' = '10000000', 'fields.payload.length' = '100' ); -- Create the BlackHole result table. CREATE TABLE blackhole_sink ( id BIGINT, payload STRING, event_time TIMESTAMP(3) ) WITH ( 'connector' = 'blackhole' ); -- Submit the job to test the pure processing throughput. INSERT INTO blackhole_sink SELECT id, payload, event_time FROM datagen_source;
- Example 3: If the job needs to split and process data, with some data written to Kafka and the other data not requiring output, use BlackHole as a placeholder.
-- Create a DataGen source table. CREATE TABLE datagen_source ( user_id INT, event_type STRING, event_time TIMESTAMP(3) ) WITH ( 'connector' = 'datagen', 'rows-per-second' = '100', 'fields.user_id.kind' = 'sequence', 'fields.user_id.start' = '1', 'fields.user_id.end' = '100000' ); -- Main output: Write data to Kafka. CREATE TABLE kafka_sink ( user_id INT, event_type STRING, event_time TIMESTAMP(3) ) WITH ( 'connector' = 'kafka', 'topic' = 'user-events', 'properties.bootstrap.servers' = 'kafka-broker:9092', 'format' = 'json' ); -- Placeholder output: Discard unnecessary data. CREATE TABLE blackhole_sink ( user_id INT, event_type STRING, event_time TIMESTAMP(3) ) WITH ( 'connector' = 'blackhole' ); -- Stream distribution: Write login events to Kafka and discard other events. EXECUTE STATEMENT SET BEGIN INSERT INTO kafka_sink SELECT user_id, event_type, event_time FROM datagen_source WHERE event_type = 'login'; INSERT INTO blackhole_sink SELECT user_id, event_type, event_time FROM datagen_source WHERE event_type <> 'login'; END;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot