Snowflake データ ソースの追加
現在、Reveal SDK は、Reveal SDK core パッケージからデータ ソースを分離する過程にあります。プロジェクトの継続的な機能を確保するために、プロジェクトに追加のパッケージをインストールすることが必要になる場合があります。詳細については、サポートされるデータ ソース トピックを参照してください。
クライアント側
手順 1 - RevealView.onDataSourcesRequested イベントのイベント ハンドラーを追加します。
var revealView = new $.ig.RevealView("#revealView");
revealView.onDataSourcesRequested = (callback) => {
//add code here
callback(new $.ig.RevealDataSources([], [], false));
};
手順 2 - RevealView.onDataSourcesRequested イベント ハンドラーで、RVSnowflakeDataSource オブジェクトの新しいインスタンスを作成します。Title プロパティを設定します。RVSnowflakeSource オブジェクトを作成したら、それをデータ ソース コレクションに追加します。
revealView.onDataSourcesRequested = (callback) => {
var snowflakeDataSource = new $.ig.RVSnowflakeDataSource();
snowflakeDataSource.title = "My Snowflake";
callback(new $.ig.RevealDataSources([snowflakeDataSource], [], false));
};
アプリケーションが実行されたら、新しい可視化を作成すると、新しく作成された Snowflake データ ソースが [データ ソースの選択] ダイアログに表示されます。
手順 3 - RVSnowflakeDataSourceItem オブジェクトの新しいインスタンスを作成して、新しいデータ ソース項目を追加します。データベース テーブルに対応する Id および Title プロパティを設定します。RVSnowflakeDataSourceItem オブジェクトを作成したら、それをデータ ソース項目コレクションに追加します。
revealView.onDataSourcesRequested = (callback) => {
var mySnowflakeDataSource = new $.ig.RVSnowflakeDataSource();
mySnowflakeDataSource.id = "MySnowflakeDataSource";
mySnowflakeDataSource.title = "My Snowflake";
var mySnowflakeDataSourceItem = new $.ig.RVSnowflakeDataSourceItem(mySnowflakeDataSource);
mySnowflakeDataSourceItem.id = "MySnowflakeDataSourceItem";
mySnowflakeDataSourceItem.title = "My Snowflake Item";
callback(new $.ig.RevealDataSources([mySnowflakeDataSource], [mySnowflakeDataSourceItem], true));
};
アプリケーションが実行されたら、新しい可視化を作成すると、新しく作成された Snowflake 項目データ ソースが [データ ソースの選択] ダイアログに表示されます。

サーバー側
手順 1 - クライアントでデータ ソースとデータ ソース項目を作成しますが、接続情報は指定しません。id、title、および/または subtitle のみを入力してください。
revealView.onDataSourcesRequested = (callback) => {
var mySnowflakeDataSource = new $.ig.RVSnowflakeDataSource();
mySnowflakeDataSource.id = "MySnowflakeDataSource";
mySnowflakeDataSource.title = "My Snowflake";
var mySnowflakeDataSourceItem = new $.ig.RVSnowflakeDataSourceItem(mySnowflakeDataSource);
mySnowflakeDataSourceItem.id = "MySnowflakeDataSourceItem";
mySnowflakeDataSourceItem.title = "My Snowflake Item";
callback(new $.ig.RevealDataSources([mySnowflakeDataSource], [mySnowflakeDataSourceItem], true));
};
手順 2 - データ ソース プロバイダーを作成します。この例では、クライアントで定義された Snowflake データベースに接続するための接続情報を提供しています。これを実現するために、使用しているデータ ソース/項目のタイプを決定し、オブジェクトで使用可能なプロパティを設定します。
- ASP.NET
- Java
- Node.js
- Node.js - TS
public class DataSourceProvider : IRVDataSourceProvider
{
public Task<RVDataSourceItem> ChangeDataSourceItemAsync(IRVUserContext userContext, string dashboardId,
RVDataSourceItem dataSourceItem)
{
if (dataSourceItem is RVSnowflakeDataSourceItem snowflakeDataSourceItem)
{
//update underlying data source
ChangeDataSourceAsync(userContext, snowflakeDataSourceItem.DataSource);
//only change the table if we have selected our custom data source item
if (snowflakeDataSourceItem.Id == "MySnowflakeDataSourceItem")
{
snowflakeDataSourceItem.Schema = "TPCDS_SF100TCL";
snowflakeDataSourceItem.Table = "CUSTOMER";
}
}
return Task.FromResult(dataSourceItem);
}
public Task<RVDashboardDataSource> ChangeDataSourceAsync(IRVUserContext userContext,
RVDashboardDataSource dataSource)
{
if (dataSource is RVSnowflakeDataSource snowflakeDataSource)
{
snowflakeDataSource.Account = "your-account";
snowflakeDataSource.Host = "your-account-host";
snowflakeDataSource.Database = "SNOWFLAKE_SAMPLE_DATA";
}
return Task.FromResult(dataSource);
}
}
public class DataSourceProvider implements IRVDataSourceProvider {
public RVDataSourceItem changeDataSourceItem(IRVUserContext userContext, String dashboardsID, RVDataSourceItem dataSourceItem) {
if (dataSourceItem instanceof RVSnowflakeDataSourceItem snowflakeDataSourceItem) {
//update underlying data source
changeDataSource(userContext, dataSourceItem.getDataSource());
//only change the table if we have selected our custom data source item
if (Objects.equals(dataSourceItem.getId(), "MySnowflakeDataSourceItem")) {
snowflakeDataSourceItem.setSchema("TPCDS_SF100TCL");
snowflakeDataSourceItem.setTable("CUSTOMER");
}
}
return dataSourceItem;
}
public RVDashboardDataSource changeDataSource(IRVUserContext userContext, RVDashboardDataSource dataSource) {
if (dataSource instanceof RVSnowflakeDataSource snowflakeDataSource) {
snowflakeDataSource.setAccount("your-account");
snowflakeDataSource.setHost("your-account-host");
snowflakeDataSource.setDatabase("SNOWFLAKE_SAMPLE_DATA");
}
return dataSource;
}
}
const dataSourceItemProvider = async (userContext, dataSourceItem) => {
if (dataSourceItem instanceof reveal.RVSnowflakeDataSourceItem) {
//update underlying data source
dataSourceProvider(userContext, dataSourceItem.dataSource);
//only change the table if we have selected our data source item
if (dataSourceItem.id === "MySnowflakeDataSourceItem") {
dataSourceItem.schema = "TPCDS_SF100TCL";
dataSourceItem.table = "CUSTOMER";
}
}
return dataSourceItem;
}
const dataSourceProvider = async (userContext, dataSource) => {
if (dataSource instanceof reveal.RVSnowflakeDataSource) {
dataSource.account = "your-account";
dataSource.host = "your-account-host";
dataSource.database = "SNOWFLAKE_SAMPLE_DATA";
}
return dataSource;
}
const dataSourceItemProvider = async (userContext: IRVUserContext | null, dataSourceItem: RVDataSourceItem) => {
if (dataSourceItem instanceof RVSnowflakeDataSourceItem) {
//update underlying data source
dataSourceProvider(userContext, dataSourceItem.dataSource);
//only change the table if we have selected our data source item
if (dataSourceItem.id === "MySnowflakeDataSourceItem") {
dataSourceItem.schema = "TPCDS_SF100TCL";
dataSourceItem.table = "CUSTOMER";
}
}
return dataSourceItem;
}
const dataSourceProvider = async (userContext: IRVUserContext | null, dataSource: RVDashboardDataSource) => {
if (dataSource instanceof RVSnowflakeDataSource) {
dataSource.account = "your-account";
dataSource.host = "your-account-host";
dataSource.database = "SNOWFLAKE_SAMPLE_DATA";
}
return dataSource;
}
このサンプルのソース コードは GitHub にあります。