> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating Data Sources

> Copy-paste examples of how to create data sources with SQL

Several authentication schemes across multiple providers are supported. For a
detailed overview of all of the provider-specific options, see the
[SQL documentation](/content/sql/ddl#sql-create-data-source).

<Info>
  Creating an authenticated *data source* may require creating a
  corresponding  [credential](/content/sql/ddl#sql-create-credential) object to
  store the authentication information and then referencing that object when
  creating the *data source*. See [Creating Credentials](/content/snippets/create-credentials)
  for examples.
</Info>

<a id="snippet-sql-create-data-source-azure" />

## Azure BLOB

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  WITH OPTIONS
  (
      CREDENTIAL = 'azure_cred',
      CONTAINER NAME = 'samplecontainer'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  USER = 'sampleacc'
  WITH OPTIONS
  (
      CONTAINER NAME = 'samplecontainer'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  USER = 'sampleacc'
  WITH OPTIONS
  (
      USE_MANAGED_CREDENTIALS = true,
      STORAGE ACCOUNT NAME = 'sampelacc',
      CONTAINER NAME = 'samplecontainer',
      TENANT ID = 'x0xxx10-00x0-0x01-0xxx-x0x0x01xx100'
  )
  ```

  ```sql Password theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  USER = 'sampleacc'
  PASSWORD = 'foobaz123'
  WITH OPTIONS
  (
      CONTAINER NAME = 'samplecontainer'
  )
  ```

  ```sql SAS Token theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  USER = 'sampleacc'
  WITH OPTIONS
  (
      CONTAINER NAME = 'samplecontainer',
      SAS TOKEN = 'sv=2015-07-08&sr=b&sig=39Up0JzHkxhUlhFEjEH9673DJxe7w6clRCg0V6lCgSo%3D&se=2016-10-18T21%A51%A337Z&sp=rcw'
  )
  ```

  ```sql Active Directory theme={null}
  CREATE DATA SOURCE azure_ds
  LOCATION = 'AZURE'
  USER = 'jdoe'
  PASSWORD = 'foobaz123'
  WITH OPTIONS
  (
      STORAGE ACCOUNT NAME = 'sampelacc',
      CONTAINER NAME = 'samplecontainer',
      TENANT ID = 'x0xxx10-00x0-0x01-0xxx-x0x0x01xx100'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-source-gcs" />

## Google Cloud Storage

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE gcs_ds
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	CREDENTIAL = 'gcs_cred',
  	GCS_BUCKET_NAME = 'gcs-public'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE DATA SOURCE gcs_ds
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	USE_MANAGED_CREDENTIALS = true,
  	GCS_BUCKET_NAME = 'gcs-public'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SOURCE gcs_ds
  LOCATION = 'GCS'
  WITH OPTIONS
  (
  	GCS_BUCKET_NAME = 'gcs-public'
  )
  ```

  ```sql User ID & Key theme={null}
  CREATE DATA SOURCE gcs_ds
  LOCATION = 'GCS'
  USER = 'auser@auser.iam.gserviceaccount.com'
  PASSWORD = '-----BEGIN PRIVATE KEY-----\nABCDEFG=\n-----END PRIVATE KEY-----\n'
  WITH OPTIONS
  (
  	GCS_BUCKET_NAME = 'gcs-public'
  )
  ```

  ```sql JSON Key theme={null}
  CREATE DATA SOURCE gcs_ds
  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-public'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-source-hdfs" />

## HDFS

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE hdfs_ds
  LOCATION = 'HDFS://example.com:8020'
  WITH OPTIONS
  (
      CREDENTIAL = 'hdfs_cred'
  )
  ```

  ```sql Password theme={null}
  CREATE DATA SOURCE hdfs_ds
  LOCATION = 'HDFS://example.com:8020'
  USER = 'jdoe'
  PASSWORD = 'foobaz123'
  ```

  ```sql Kerberos Keytab theme={null}
  CREATE DATA SOURCE hdfs_ds
  LOCATION = 'HDFS://example.com:8020'
  USER = 'jdoe'
  WITH OPTIONS
  (
      KERBEROS KEYTAB = '/path/to/jdoe.keytab'
  )
  ```

  ```sql Kerberos Token theme={null}
  CREATE DATA SOURCE hdfs_ds
  LOCATION = 'HDFS://example.com:8020'
  USER = 'jdoe'
  WITH OPTIONS
  (
      USE KERBEROS = true
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-source-jdbc" />

## JDBC

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE jdbc_ds
  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'
  )
  ```

  ```sql Password theme={null}
  CREATE DATA SOURCE jdbc_ds
  LOCATION = 'jdbc:postgresql://localhost:5432/ki_home'
  USER = 'auser'
  PASSWORD = 'Passw0rd!'
  WITH OPTIONS
  (
  	JDBC_DRIVER_CLASS_NAME = 'org.postgresql.Driver',
  	JDBC_DRIVER_JAR_PATH = 'kifs://drivers/postgresql.jar'
  )
  ```
</CodeGroup>

<a id="snippet-sql-create-data-source-kafka" />

## Kafka (Apache)

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE kafka_ds
  LOCATION = 'KAFKA://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample',
      CREDENTIAL = 'kafka_cred'
  )
  ```

  ```sql Credential w/ Schema Registry theme={null}
  CREATE DATA SOURCE kafka_ds
  LOCATION = 'KAFKA://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample',
      CREDENTIAL = 'kafka_cred',
      SCHEMA_REGISTRY_LOCATION = 'https://example.com:8082',
      SCHEMA_REGISTRY_CREDENTIAL = 'kafka_sr_cred'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SOURCE kafka_ds
  LOCATION = 'KAFKA://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample'
  )
  ```
</CodeGroup>

<Info>
  Creating an authenticated Kafka *data source* requires creating a
  corresponding [credential](/content/sql/ddl#sql-create-credential) object to
  store the Kafka credentials and then referencing that object when creating
  the *data source*.  See [Kafka (Apache)](/content/snippets/create-credentials#snippet-sql-create-credential-kafka)
  for examples.
</Info>

<a id="snippet-sql-create-data-source-confluent" />

## Kafka (Confluent)

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE confluent_ds
  LOCATION = 'CONFLUENT://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample',
      CREDENTIAL = 'confluent_cred'
  )
  ```

  ```sql Credential w/ Schema Registry theme={null}
  CREATE DATA SOURCE confluent_ds
  LOCATION = 'CONFLUENT://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample',
      CREDENTIAL = 'confluent_cred',
      SCHEMA_REGISTRY_LOCATION = 'https://example.com:8082',
      SCHEMA_REGISTRY_CREDENTIAL = 'confluent_sr_cred'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE DATA SOURCE confluent_ds
  LOCATION = 'CONFLUENT://example.com:9092'
  WITH OPTIONS
  (
      KAFKA_TOPIC_NAME = 'sample'
  )
  ```
</CodeGroup>

<Info>
  Creating an authenticated Confluent *data source* requires creating a
  corresponding [credential](/content/sql/ddl#sql-create-credential) object to
  store the Confluent credentials and then referencing that object when
  creating the *data source*.  See
  [Kafka (Confluent)](/content/snippets/create-credentials#snippet-sql-create-credential-confluent) for examples.
</Info>

<a id="snippet-sql-create-data-source-s3" />

## S3

<CodeGroup>
  ```sql Credential theme={null}
  CREATE DATA SOURCE s3_ds
  LOCATION = 'S3'
  WITH OPTIONS
  (
      CREDENTIAL = 's3_cred',
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-2'
  )
  ```

  ```sql Public (No Auth) theme={null}
  CREATE OR REPLACE DATA SOURCE s3_ds
  LOCATION = 'S3'
  WITH OPTIONS
  (
      BUCKET NAME = 'quickstartpublic',
      REGION = 'us-west-1'
  )
  ```

  ```sql Managed Credentials theme={null}
  CREATE OR REPLACE DATA SOURCE s3_ds
  LOCATION = 'S3'
  WITH OPTIONS
  (
      USE_MANAGED_CREDENTIALS = true,
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-1'
  )
  ```

  ```sql Access Key theme={null}
  CREATE DATA SOURCE s3_ds
  LOCATION = 'S3'
  USER = 'AKIAIOSFODNN7EXAMPLE'
  PASSWORD = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
  WITH OPTIONS
  (
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-2'
  )
  ```

  ```sql IAM Role theme={null}
  CREATE DATA SOURCE s3_ds
  LOCATION = 'S3'
  USER = 'AKIAIOSFODNN7EXAMPLE'
  PASSWORD = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
  WITH OPTIONS
  (
      BUCKET NAME = 'samplebucket',
      REGION = 'us-east-2',
      S3_AWS_ROLE_ARN = 'arn:aws:iam::123456789012:user/JohnDoe'
  )
  ```
</CodeGroup>
