Snowflakeは、クラウドベースの データストレージおよび分析サービスです。 CSVファイルやテーブルなどの構造化データと、JSON、Avro、Parquetなどの半構造化データの両方をサポートするリレーショナルデータベースを提供します。データソースとしても、分析ストレージとしても使用できます。
Connector Configuration
Snowflakeには以下のパラメータが必要です:
Parameter | Description |
---|---|
| A Snowflake endpoint based on account name |
| Name of the user's account (provided by Snowflake) |
| Password for the specified user |
| Default database to use once connected. Data source parameter |
| Virtual warehouse to use once connected |
Example
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'supportsNativeQueries=true'
) ;;
Translator Properties
Amazon AWS S3 Upload
標準のJDBCプロトコルを使用してSnowflakeにデータを挿入すると、非常に時間がかかることがあるため、生産的な使用にはAmazon AWS S3(S3LOAD)を構成して使用することをお勧めします。
S3LOADを構成するには、以下のトランスレータパラメータが必要です:
Parameter | Description |
---|---|
| Explicitly specifies the S3LOAD mode |
| AWS S3 region endpoint |
| Optional parameter; bucket name to upload data files to. It is not necessarily an already existing bucket: you can use the |
| Optional parameter; specifies if the bucket set in the |
| Optional parameter; prefix of the temporary bucket to upload data files to if |
| AWS S3 key ID |
| AWS S3 secret key |
Examples
1. データソースとしてのSnowflake
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'supportsNativeQueries=true,uploadMode=s3Load,region=<region>,bucketName=<bucket_name>,createBucket=true,keyId=<key_ID>,secretKey="<secret_key>"'
) ;;
2. 分析ストレージとしてのSnowflake
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'supportsNativeQueries=true,uploadMode=s3Load,region=<region>,bucketName=<bucket_name>,createBucket=true,keyId=<key_ID>,secretKey="<secret_key>"'
) ;;
CALL SYSADMIN.setCurrentDWH(
'dwh'
,
'PUBLIC'
) ;;
S3バケットからデータを読み取るには、バケットのセキュリティおよびアクセス管理ポリシーで、Snowflakeがバケットにアクセスすることを許可する必要があります。指定したS3バケットにアクセスするために必要なPermissionを持つIAM Userが存在する必要があります。この1回限りのセットアップでは、バケットにアクセス許可を設定し、必要な許可をIAM Userに関連付けます。アクセス管理については、 Configuring AWS IAM User Credentialsをご参照ください。
Amazon AWS S3アップロードのプロキシ設定は、System Propertiesを使用して設定できます。
Internal Stage Upload
Amazon AWS S3アップロードモードの代替として、Internal Stage経由でデータアップロードを構成することができます。
必要なTRANSLATIONプロパティはこちらです:
Parameter | Description |
---|---|
|
|
| Value: a path to a folder (relative or absolute). Specifies the folder to be used for creating temporary files instead of the system configured one. If not specified, the default OS tmp folder is used |
| If set to |
| The name of the internal stage that will be used or created for uploading the file. If not set, a named stage with a unique name starting with TEMPORARY_NAMED_STAGE_ will be created for uploading the file and removed when done being used by the command |
Example
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'supportsNativeQueries=true, uploadMode=INTERNAL_STAGE, tempFolder=D:/tmp,keepTempFiles=true, internalStageName=justSomeName'
) ;;
INTERNAL_STAGE
upload mode available since v4.8
Microsoft Azure Blob Storage Upload
上記のモードとは別に、Microsoft Azure Blob Storage経由でのデータアップロードを設定することもできます。
以下に必要な TRANSLATION パラメータを示します:
Parameter | Description |
---|---|
| Microsoft Azure Blob Storage upload mode: |
| Microsoft Azure Blob Storage account name |
| Microsoft Azure Blob Storage account key |
| Name of the container defined in the Microsoft Azure Blob Storage account. This property is case-sensitive as the container name is also case-sensitive in Microsoft Azure Blob Storage |
| Endpoint protocol |
| Value: a path to a folder (relative or absolute). Specifies the folder to be used for creating temporary files instead of the system configured one. If not specified, the default OS tmp folder is used |
| If set to |
| If set to |
| Key for encrypting data while it is stored in the Azure Blob Storage, must be a base64-encoded 128, 192, or 256-bit value. When set to an empty value (i.e. |
Microsoft Azure Blobコンテナ内のデータファイルへのセキュアアクセスを設定するには、SASトークンの作成またはSnowflake Storage統合の設定の2つのオプションのいずれかを使用します。
Connecting via SAS Token
SAS トークンを使用するには、sasToken
プロパティを、Snowflake から Microsoft Azure Blob Storage にアクセスする際に使用する SAS トークン( )で構成し、以下のパラメータを指定します:
Parameter | Description |
---|---|
| SAS token used to access the Microsoft Azure Blob Storage from Snowflake |
| Specifies if the container set in the |
以下の点にご留意ください:
containerName
パラメータは、このパラメータが設定されていない場合に使用される(トランザクションごとに作成および削除される)一時的な Azure Blob Storage コンテナーを指定します;- デフォルトでは、
azureKey
が設定されていない場合、データはサーバーによって生成されたキーで暗号化されます。
Example:
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'uploadMode=blob_azure,supportsNativeQueries=true,storageAccountName=<storageAccountName>,storageAccountKey=<storageAccountKey>,sasToken="<sasToken>",defaultEndpointsProtocol=https,tempFolder=d:\tmp\azure\,keepTempFiles=false'
) ;;
Connecting via Snowflake Storage Integration
Snowflake Storage Integrationを使用するには、以下のプロパティを構成します:
Property | Description |
---|---|
| Fully qualified name of the external stage predefined and configured in Snowflake |
| Name of the container defined in the Microsoft Azure Blob Storage account. Must be set to the same container as defined in Please note that this property is case-sensitive as the container name is also case-sensitive in Microsoft Azure Blob Storage |
以下の点にご留意ください:
-
azureKey
パラメータの値は、外部ステージのmaster_key
パラメータで定義された値と同じでなければなりません; - デフォルトでは、
azureKey
が設定されていない場合、データは暗号化されません。
Example:
CALL SYSADMIN.createConnection(
name
=>
'snowflake'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'snowflake'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'uploadMode=blob_azure,supportsNativeQueries=true,storageAccountName=<storageAccountName>,storageAccountKey=<storageAccountKey>,externalStageName=<fully_qualified_name>,containerName=<case_sensitive_test_containrer_name>,defaultEndpointsProtocol=https,tempFolder=d:\tmp\azure\,keepTempFiles=false'
) ;;
Session Keepalive
デフォルトでは、Snowflake はfour hours of inactivityの後、開いているセッションを終了します。これを防ぐには、JDBC パラメータ CLIENT_SESSION_KEEP_ALIVE
を TRUE
に設定します:
CALL SYSADMIN.createConnection(
name
=>
'dwh'
, jbossCLITemplateName =>
'snowflake'
, connectionOrResourceAdapterProperties =>
'host=<your_account_name.snowflakecomputing.com,db=<database>,user-name=<user_name>,password=<user_password>,warehouse=<warehouse>,jdbc-properties="CLIENT_SESSION_KEEP_ALIVE=TRUE"'
) ;;
CALL SYSADMIN.createDataSource(
name
=>
'dwh'
, translator =>
'snowflake'
, modelProperties =>
'importer.defaultSchema=PUBLIC,importer.schemaPattern=PUBLIC,importer.useFullSchemaName=FALSE,importer.tableTypes="TABLE,VIEW"'
, translatorProperties =>
'supportsNativeQueries=true,uploadMode=s3Load,region=<region>,bucketName=<bucket_name>,keyId=<key_ID>,secretKey="<secret_key>"'
) ;;
CALL SYSADMIN.setCurrentDWH(
'dwh'
,
'PUBLIC'
) ;;
Miscellanea
Snowflakeデータソースでは、インデックスとネイティブ統計はサポートされていません。