Skip to content

You are viewing documentation for Immuta version 2023.3.

For the latest version, view our documentation for Immuta SaaS or the latest self-hosted version.

Snowflake Data Source API Reference Guide

The snowflake endpoint allows you to connect and manage Snowflake data sources in Immuta.

Note

Additional fields may be included in some responses you receive; however, these attributes are for internal purposes and are therefore undocumented.

Snowflake workflow

  1. Create a data source.
  2. Get information about a data source.
  3. Manage data sources.

Create a data source

Data source duplicates

In order to avoid two data sources referencing the same table, users can not create duplicate data sources. If you attempt to create a duplicate data source using the API, you will encounter a warning stating "duplicate tables are specified in the payload."

Endpoint

Method Path Purpose
POST /snowflake/handler Save the provided connection information as a data source.

Query Parameters

None.

Payload Parameters

Attribute Description Required
private boolean When false, the data source will be publicly available in the Immuta UI. Yes
blobHandler array[object] The parameters for this array include scheme ("https") and url (an empty string). Yes
blobHandlerType string Describes the type of underlying blob handler that will be used with this data source (e.g., MS SQL). Yes
recordFormat string The data format of blobs in the data source, such as json, xml, html, or jpeg. Yes
type string The type of data source: ingested (metadata will exist in Immuta) or queryable (metadata is dynamically queried). Yes
name string The name of the data source. It must be unique within the Immuta instance. Yes
sqlTableName string A string that represents this data source's table in the Query Engine. Yes
organization string The organization that owns the data source. Yes
category string The category of the data source. No
description string The description of the data source. No
owner array[object] Users and groups that should be added as owners to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [3, 5], "groups": [4, 1999] }. No
expert array[object] Users and groups that should be added as expert users to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [87, 199], "groups": [324] }. No
ingest array[object] Users and groups that should be added as ingest users to this data source. Profiles must be a list of profile IDs and groups must be a list of group IDs: { "profiles": [34, 23], "groups": [32] }. No
hasExamples boolean When true, the data source contains examples. No

Response Parameters

Attribute Description
id integer The handler ID.
dataSourceId integer The ID of the data source.
warnings string This message describes issues with the created data source, such as the data source being unhealthy.
connectionString string The connection string used to connect the data source to Immuta.

Request example

This request creates a Snowflake data source.

curl \
    --request POST \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/snowflake/handler

Payload example

{
  "handler": {
    "metadata": {
      "ssl": true,
      "userFiles": [],
      "authenticationMethod": "userPassword",
      "username": "user",
      "password": "yourpassword",
      "port": 443,
      "hostname": "demo.us-east-1.snowflakecomputing.com",
      "warehouse": "YOUR_WH",
      "database": "ANALYTICS",
      "schema": "TEST",
      "table": "CUSTOMERS",
      "nativeViewName": "customers_immuta",
      "nativeSchemaName": "test_immuta",
      "nativeWorkspaceName": "immuta_analytics",
      "schemaProjectName": "Test",
      "bodataSchemaName": "test",
      "columns": [{
        "name": "CUSTOMER_ID",
        "dataType": "numeric(38,0)",
        "remoteType": "number(38,0)",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "FIRST_NAME",
        "dataType": "text",
        "remoteType": "varchar(16777216)",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "LAST_NAME",
        "dataType": "text",
        "remoteType": "varchar(16777216)",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "FIRST_ORDER",
        "dataType": "date",
        "remoteType": "date",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "MOST_RECENT_ORDER",
        "dataType": "date",
        "remoteType": "date",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "NUMBER_OF_ORDERS",
        "dataType": "numeric(18,0)",
        "remoteType": "number(18,0)",
        "isPrimaryKey": false,
        "nullable": true
      }, {
        "name": "TOTAL_ORDER_AMOUNT",
        "dataType": "numeric",
        "remoteType": "number(38,6)",
        "isPrimaryKey": false,
        "nullable": true
      }],
      "eventTime": "FIRST_ORDER",
      "staleDataTolerance": 86400,
      "bodataTableName": "customers",
      "dataSourceName": "Customers"
    }
  },
  "dataSource": {
    "blobHandler": {
      "scheme": "https",
      "url": ""
    },
    "blobHandlerType": "Snowflake",
    "recordFormat": "",
    "type": "queryable",
    "schemaEvolutionId": null,
    "columnEvolutionEnabled": true,
    "name": "Customers",
    "sqlTableName": "customers"
  },
  "schemaEvolution": {
    "ownerProfileId": 2,
    "config": {
      "nameTemplate": {
        "nameFormat": "<Schema> <Tablename>",
        "tableFormat": "<tablename>",
        "sqlSchemaNameFormat": "<schema>",
        "schemaProjectNameFormat": "<Schema>"
      }
    },
    "schemas": []
  }
}

Response example

{
  "id": 30,
  "dataSourceId": 30,
  "warnings": []
}

Get information about a data source

Endpoint

Method Path Purpose
GET /snowflake/handler/{handlerId} Get the handler metadata associated with the provided handler ID.

Query Parameters

Attribute Description Required
handlerId integer The ID of the handler. Yes
skipCache boolean When true, will skip the handler cache when retrieving metadata. No

Response Parameters

Attribute Description
body array[object] Metadata about the data source, including the data source ID, schema, database, and connection string.

Request example

This request returns metadata for the handler with the ID 30.

curl \
    --request GET \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://demo.immuta.com/snowflake/handler/30

Response example

{
  "dataSourceId": 30,
  "metadata": {
    "ssl": true,
    "port": 443,
    "query": null,
    "table": "CUSTOMERS",
    "schema": "TEST",
    "database": "ANALYTICS",
    "hostname": "demo.us-east-1.snowflakecomputing.com",
    "username": "user",
    "eventTime": "FIRST_ORDER",
    "userFiles": [],
    "warehouse": "YOUR_WH",
    "dataSourceName": "Customers",
    "bodataTableName": "customers",
    "highCardinality": "CUSTOMER_ID",
    "bodataSchemaName": "test",
    "columnsNormalized": true,
    "schemaProjectName": "Test",
    "staleDataTolerance": 86400,
    "authenticationMethod": "userPassword"
  },
  "type": "odbcHandler",
  "connectionString": "user@demo.us-east-1.snowflakecomputing.com:443/ANALYTICS",
  "remoteTableDescription": "[{\"name\":\"CUSTOMER_ID\",\"type\":\"NUMBER(38,0)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"FIRST_NAME\",\"type\":\"VARCHAR(16777216)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"LAST_NAME\",\"type\":\"VARCHAR(16777216)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"FIRST_ORDER\",\"type\":\"DATE\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"MOST_RECENT_ORDER\",\"type\":\"DATE\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"NUMBER_OF_ORDERS\",\"type\":\"NUMBER(18,0)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"TOTAL_ORDER_AMOUNT\",\"type\":\"NUMBER(38,6)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null}]",
  "id": 30,
  "createdAt": "2021-10-01T16:19:23.562Z",
  "updatedAt": "2021-10-01T16:19:28.556Z",
  "dbms": {
    "name": "snowflake"
  }
}

Manage data sources

Method Path Purpose
PUT /snowflake/handler/{handlerId} Update the data source metadata associated with the provided handler ID. This endpoint does not perform partial updates, but will allow the dictionary to be omitted. In this case, it uses the current dictionary.
PUT /snowflake/bulk Update the data source metadata associated with the provided connection string.
PUT /snowflake/handler/{handlerId}/triggerHighCardinalityJob Recalculate the high cardinality column for the specified data source.
PUT /snowflake/handler/{handlerId}/refreshNativeViewJob Refresh the native view of a data source.

Update a specific data source

Endpoint

Method Path Purpose
PUT /snowflake/handler/{handlerId} Update the data source metadata associated with the provided handler ID. This endpoint does not perform partial updates, but will allow the dictionary to be omitted. In this case, it uses the current dictionary.

Query Parameters

Attribute Description Required
handlerId integer The ID of the handler. Yes
skipCache boolean When true, will skip the handler cache when retrieving metadata. No

Payload Parameters

Attribute Description Required
handler metadata Includes metadata about the handler, such as ssl, port, database, hostname, username, and password. Yes
connectionString string The connection string used to connect to the data source. Yes

Response Parameters

Attribute Description
id integer The ID of the handler.
ca string The certificate authority.
columns array[object] This is a Data Dictionary object, which provides metadata about the columns in the data source, including the name and data type of the column.

Request example

This request updates the metadata for the data source with the handler ID 30.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/snowflake/handler/30
Payload example

The payload below updates the eventTime to MOST_RECENT_ORDER.

{
  "handler": {
    "policyHandler": null,
    "dataSourceId": 30,
    "metadata": {
      "ssl": true,
      "port": 443,
      "table": "CUSTOMERS",
      "schema": "TEST",
      "database": "ANALYTICS",
      "hostname": "demo.us-east-1.snowflakecomputing.com",
      "username": "user",
      "eventTime": "MOST_RECENT_ORDER",
      "userFiles": [],
      "warehouse": "YOUR_WH",
      "dataSourceName": "Customers",
      "bodataTableName": "customers",
      "highCardinality": "CUSTOMER_ID",
      "bodataSchemaName": "test",
      "columnsNormalized": true,
      "schemaProjectName": "Test",
      "staleDataTolerance": 86400,
      "authenticationMethod": "userPassword",
      "columns": [{
        "name": "CUSTOMER_ID",
        "dataType": "numeric(38,0)",
        "nullable": true,
        "remoteType": "number(38,0)",
        "isPrimaryKey": false,
        "remoteColumn": "CUSTOMER_ID"
      }, {
        "name": "FIRST_NAME",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(16777216)",
        "isPrimaryKey": false,
        "remoteColumn": "FIRST_NAME"
      }, {
        "name": "LAST_NAME",
        "dataType": "text",
        "nullable": true,
        "remoteType": "varchar(16777216)",
        "isPrimaryKey": false,
        "remoteColumn": "LAST_NAME"
      }, {
        "name": "FIRST_ORDER",
        "dataType": "date",
        "nullable": true,
        "remoteType": "date",
        "isPrimaryKey": false,
        "remoteColumn": "FIRST_ORDER"
      }, {
        "name": "MOST_RECENT_ORDER",
        "dataType": "date",
        "nullable": true,
        "remoteType": "date",
        "isPrimaryKey": false,
        "remoteColumn": "MOST_RECENT_ORDER"
      }, {
        "name": "NUMBER_OF_ORDERS",
        "dataType": "numeric(18,0)",
        "nullable": true,
        "remoteType": "number(18,0)",
        "isPrimaryKey": false,
        "remoteColumn": "NUMBER_OF_ORDERS"
      }, {
        "name": "TOTAL_ORDER_AMOUNT",
        "dataType": "numeric",
        "nullable": true,
        "remoteType": "number(38,6)",
        "isPrimaryKey": false,
        "remoteColumn": "TOTAL_ORDER_AMOUNT"
      }]
    },
    "type": "odbcHandler",
    "connectionString": "user@demo.us-east-1.snowflakecomputing.com:443/ANALYTICS",
    "remoteTableDescription": "[{\"name\":\"CUSTOMER_ID\",\"type\":\"NUMBER(38,0)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"FIRST_NAME\",\"type\":\"VARCHAR(16777216)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"LAST_NAME\",\"type\":\"VARCHAR(16777216)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"FIRST_ORDER\",\"type\":\"DATE\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"MOST_RECENT_ORDER\",\"type\":\"DATE\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"NUMBER_OF_ORDERS\",\"type\":\"NUMBER(18,0)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null},{\"name\":\"TOTAL_ORDER_AMOUNT\",\"type\":\"NUMBER(38,6)\",\"kind\":\"COLUMN\",\"null?\":\"Y\",\"default\":null,\"primary key\":\"N\",\"unique key\":\"N\",\"check\":null,\"expression\":null,\"comment\":null,\"policy name\":null}]",
    "id": 30,
    "createdAt": "2021-10-01T16:19:23.562Z",
    "updatedAt": "2021-10-01T17:19:35.853Z",
    "dbms": {
      "name": "snowflake"
    }
  }
}

Response example

{
  "id": 30,
  "ca": ["-----BEGIN CERTIFICATE-----\ncertificatedata\n-----END CERTIFICATE-----"],
  "metadata": {
    "columns": [{
      "name": "customer_id",
      "dataType": "numeric(38,0)",
      "remoteType": "number(38,0)",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "CUSTOMER_ID"
    }, {
      "name": "first_name",
      "dataType": "text",
      "remoteType": "varchar(16777216)",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "FIRST_NAME"
    }, {
      "name": "last_name",
      "dataType": "text",
      "remoteType": "varchar(16777216)",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "LAST_NAME"
    }, {
      "name": "first_order",
      "dataType": "date",
      "remoteType": "date",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "FIRST_ORDER"
    }, {
      "name": "most_recent_order",
      "dataType": "date",
      "remoteType": "date",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "MOST_RECENT_ORDER"
    }, {
      "name": "number_of_orders",
      "dataType": "numeric(18,0)",
      "remoteType": "number(18,0)",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "NUMBER_OF_ORDERS"
    }, {
      "name": "total_order_amount",
      "dataType": "numeric",
      "remoteType": "number(38,6)",
      "isPrimaryKey": false,
      "nullable": true,
      "remoteColumn": "TOTAL_ORDER_AMOUNT"
    }]
  }
}

Update multiple data sources

Endpoint

Method Path Purpose
PUT /snowflake/bulk Update the data source metadata associated with the provided connection string.

Query Parameters

None.

Payload Parameters

Attribute Description Required
handler metadata Includes metadata about the handler, such as ssl, port, database, hostname, username, and password. Yes
connectionString string The connection string used to connect to the data sources. Yes

Response Parameters

Attribute Description
bulkId string The ID of the bulk data source update.
connectionString string The connection string shared by the data sources bulk updated.
jobsCreated integer The number of jobs that ran to update the data sources; this number corresponds to the number of data sources updated.

Request example

This request updates the metadata for all data sources with the connection string specified in example-payload.json.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    --data @example-payload.json \
    https://demo.immuta.com/snowflake/bulk
Payload example

The payload below updates the database to ANALYST_DEMO for the provided connection string.

{
  "handler": {
    "metadata": {
      "ssl": true,
      "port": 443,
      "database": "ANALYST_DEMO",
      "hostname": "demo.us-east-1.snowflakecomputing.com",
      "username": "yourusername",
      "userFiles": [],
      "warehouse": "YOUR_WH",
      "authenticationMethod": "userPassword",
      "password": "yourpassword"
    }
  },
  "connectionString": "demo.us-east-1.snowflakecomputing.com:443/ANALYST_DEMO"
}

Response example

{
  "bulkId": "bulk_ds_update_54ada6bhashedvaluea0c80cecd9d62",
  "jobsCreated": 5
}

Recalculate the high cardinality column for a data source

Endpoint

Method Path Purpose
PUT /snowflake/handler/{handlerId}/triggerHighCardinalityJob Recalculate the high cardinality column for the specified data source.

Query Parameters

Attribute Description Required
handlerId integer The ID of the handler. Yes

Response Parameters

The response returns a string of characters that identify the high cardinality job run.

Request example

This request re-runs the job that calculates the high cardinality column for the data source with the handler ID 30.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://demo.immuta.com/snowflake/handler/30/triggerHighCardinalityJob

Response example

c12fd320-22d8-11ec-b2b8-874838eeef05

Refresh a native view

Endpoint

Method Path Purpose
PUT /snowflake/handler/{handlerId}/refreshNativeViewJob Refresh the native view of a data source.

Query Parameters

Attribute Description Required
handlerId integer The ID of the handler. Yes

Response Parameters

The response returns a string of characters that identifies the refresh view job run.

Request example

This request refreshes the view for the data source with the handler ID 7.

curl \
    --request PUT \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer dea464c07bd07300095caa8" \
    https://demo.immuta.com/snowflake/handler/7/refreshNativeViewJob

Response example

53c256d0-eb57-11ec-b275-d95a8e998142