Creating Data Sinks

Copy-paste examples of how to create data sinks with SQL

Several authentication schemes across multiple consumers are supported. For a detailed overview of all of the consumer-specific options, see the SQL documentation.

Note

Creating an authenticated data sink may require creating a corresponding credential object to store the authentication information and then referencing that object when creating the data sink. See Creating Credentials for examples.

Azure BLOB

Credential
1
2
3
4
5
6
7
CREATE DATA SINK azure_dsink
LOCATION = 'AZURE'
WITH OPTIONS
(
    CREDENTIAL = 'azure_cred',
    CONTAINER NAME = 'samplecontainer'
)
Managed Credentials
1
2
3
4
5
6
7
8
9
CREATE DATA SINK azure_dsink
LOCATION = 'AZURE'
WITH OPTIONS
(
    USE_MANAGED_CREDENTIALS = true,
    STORAGE ACCOUNT NAME = 'sampleacc',
    CONTAINER NAME = 'samplecontainer',
    TENANT ID = 'x0xxx10-00x0-0x01-0xxx-x0x0x01xx100'
)

CData

Credential
1
2
3
CREATE DATA SINK cdata_dsink
LOCATION = 'jdbc:postgresql:Server=localhost;Port=5432;Database=ki_home'
WITH OPTIONS (CREDENTIAL = 'cdata_cred')
Password in URL
1
2
CREATE DATA SINK cdata_dsink
LOCATION = 'jdbc:postgresql:Server=localhost;Port=5432;Database=ki_home;User=dsink_user;Password=dsink_pass'

Google Cloud Storage

Credential
1
2
3
4
5
6
7
CREATE DATA SINK gcs_dsink
LOCATION = 'GCS'
WITH OPTIONS
(
    CREDENTIAL = 'gcs_cred',
    GCS_BUCKET_NAME = 'gcs-private'
)
Managed Credentials
1
2
3
4
5
6
7
CREATE DATA SINK gcs_dsink
LOCATION = 'GCS'
WITH OPTIONS
(
    USE_MANAGED_CREDENTIALS = true,
    GCS_BUCKET_NAME = 'gcs-private'
)
Public (No Auth)
1
2
3
CREATE DATA SINK gcs_dsink
LOCATION = 'GCS'
WITH OPTIONS (GCS_BUCKET_NAME = 'gcs-public')
JSON Key
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
CREATE DATA SINK gcs_dsink
LOCATION = 'GCS'
WITH OPTIONS
(
    GCS_SERVICE_ACCOUNT_KEYS = '
    {
        "type": "service_account",
        "project_id": "auser",
        "private_key_id": "abcdef1234567890",
        "private_key": "-----BEGIN PRIVATE KEY-----\nABCDEFG=\n-----END PRIVATE KEY-----\n",
        "client_email": "auser@auser.iam.gserviceaccount.com",
        "client_id": "1234567890",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/auser%40auser.iam.gserviceaccount.com"
    }',
    GCS_BUCKET_NAME = 'gcs-private'
)

HDFS

Credential
1
2
3
4
5
6
CREATE DATA SINK hdfs_dsink
LOCATION = 'HDFS://example.com:8020'
WITH OPTIONS
(
    CREDENTIAL = 'hdfs_cred'
)

JDBC

Credential
1
2
3
4
5
6
7
8
CREATE DATA SINK jdbc_dsink
LOCATION = 'jdbc:postgresql://localhost:5432/ki_home'
WITH OPTIONS
(
    CREDENTIAL = 'jdbc_cred',
    JDBC_DRIVER_CLASS_NAME = 'org.postgresql.Driver',
    JDBC_DRIVER_JAR_PATH = 'kifs://drivers/postgresql.jar'
)
Password in URL
1
2
3
4
5
6
7
CREATE DATA SINK jdbc_dsink
LOCATION = 'jdbc:postgresql://localhost:5432/ki_home?user=dsink_user&password=Passw0rd!'
WITH OPTIONS
(
    JDBC_DRIVER_CLASS_NAME = 'org.postgresql.Driver',
    JDBC_DRIVER_JAR_PATH = 'kifs://drivers/postgresql.jar'
)

Kafka

Credential
1
2
3
4
5
6
7
CREATE DATA SINK kafka_dsink
LOCATION = 'kafka://example.com:9092'
WITH OPTIONS
(
    KAFKA_TOPIC_NAME = 'sample',
    CREDENTIAL = 'kafka_cred'
)
Public (No Auth)
1
2
3
4
5
6
CREATE DATA SINK kafka_dsink
LOCATION = 'kafka://example.com:9092'
WITH OPTIONS
(
    KAFKA_TOPIC_NAME = 'sample'
)

Local Table

User Auth
1
2
CREATE DATA SINK local_table_dsink
LOCATION = 'table://example.local_target_table'

S3

Credential
1
2
3
4
5
6
7
8
CREATE DATA SINK s3_dsink
LOCATION = 'S3'
WITH OPTIONS
(
    CREDENTIAL = 's3_cred',
    BUCKET NAME = 'samplebucket',
    REGION = 'us-east-2'
)
Managed Credentials
1
2
3
4
5
6
7
8
CREATE OR REPLACE DATA SINK s3_dsink
LOCATION = 'S3'
WITH OPTIONS
(
    USE_MANAGED_CREDENTIALS = true,
    BUCKET NAME = 'samplebucket',
    REGION = 'us-east-1'
)
Public (No Auth)
1
2
3
4
5
6
7
CREATE DATA SINK s3_dsink
LOCATION = 'S3'
WITH OPTIONS
(
    BUCKET NAME = 'quickstartpublic',
    REGION = 'us-west-1'
)

Webhook

HTTP
1
2
CREATE DATA SINK http_dsink
LOCATION = 'http://example.com/webhook'
HTTPS
1
2
3
CREATE DATA SINK https_dsink
LOCATION = 'https://example.com/webhook'
WITH OPTIONS (CREDENTIAL = 'https_cred')