From 664eb1644d620f748ab3a3e1709fef9ef36beb97 Mon Sep 17 00:00:00 2001 From: Viktor Date: Fri, 6 Dec 2024 11:36:11 +0700 Subject: [PATCH] Create Snowflake sandbox example --- .../DashboardCreators/SnowFlakeDashboard.cs | 57 +++++++++++++++++++ e2e/Sandbox/MainWindow.xaml.cs | 4 +- e2e/Sandbox/Reveal/AuthenticationProvider.cs | 5 ++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs new file mode 100644 index 00000000..4c53e9fd --- /dev/null +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -0,0 +1,57 @@ +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations; +using Sandbox.DashboardFactories; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sandbox.DashboardCreators +{ + internal class SnowflakeDashboard : IDashboardCreator + { + public string Name => "Snowflake Dashboard"; + + public RdashDocument CreateDashboard() + { + var snowflakeDS = new SnowflakeDataSource() + { + Id = "SnowflakeDSId", + Title = "Snowflake Data source", + Subtitle = "Snowflake Subtitle", + Account = "pqwkobs-xb90908", + DefaultRefreshRate = "120", + Host = "gpiskyj-al16914.snowflakecomputing.com", + Database = "SNOWFLAKE_SAMPLE_DATA", + //Role + Warehouse = "COMPUTE_WH", + Schema = "TPCDS_SF100TCL" + }; + + var snowflakeDSI = new SnowflakeDataSourceItem("Snowflake DSI Title", snowflakeDS) + { + Id = "SnowflakeDSItemId", + Title = "Snowflake data source Item", + Subtitle = "Snowflake data source Item Subtitle", + CustomQuery = "Select O_ORDERKEY, O_ORDERPRIORITY, O_CUSTKEY from ORDERS", + Schema = "TPCH_SF10", + Table = "ORDERS", + Database = "SNOWFLAKE_SAMPLE_DATA", + Fields = new List + { + new NumberField("O_ORDERKEY"), + new NumberField("O_CUSTKEY"), + new TextField("O_ORDERPRIORITY"), + } + }; + + var document = new RdashDocument("Snowflake Dashboard"); + + document.Visualizations.Add(new PieChartVisualization("Snowflake Order Priorities", snowflakeDSI) + .SetLabel("O_ORDERPRIORITY").SetValues("O_CUSTKEY")); + return document; + } + } +} diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 1992d24c..b1f73518 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,6 +22,7 @@ using Reveal.Sdk.Data.Rest; using Reveal.Sdk.Data.Snowflake; using Reveal.Sdk.Dom; +using Sandbox.DashboardCreators; using Sandbox.DashboardFactories; using Sandbox.RevealSDK; using System; @@ -51,6 +52,7 @@ public partial class MainWindow : Window new RestDataSourceDashboard(), new SalesDashboard(), new SqlServerDataSourceDashboards(), + new SnowflakeDashboard(), }; public MainWindow() @@ -59,7 +61,7 @@ public MainWindow() RevealSdkSettings.DataSourceProvider = new Sandbox.RevealSDK.DataSourceProvider(); RevealSdkSettings.AuthenticationProvider = new AuthenticationProvider(); - RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices(); + RevealSdkSettings.DataSources.RegisterMicrosoftSqlServer().RegisterMicrosoftAnalysisServices().RegisterSnowflake(); LoadDashboards(); diff --git a/e2e/Sandbox/Reveal/AuthenticationProvider.cs b/e2e/Sandbox/Reveal/AuthenticationProvider.cs index 07e9fce2..24122aba 100644 --- a/e2e/Sandbox/Reveal/AuthenticationProvider.cs +++ b/e2e/Sandbox/Reveal/AuthenticationProvider.cs @@ -1,6 +1,7 @@ using Reveal.Sdk.Data; using Reveal.Sdk.Data.Microsoft.AnalysisServices; using Reveal.Sdk.Data.Microsoft.SqlServer; +using Reveal.Sdk.Data.Snowflake; using System.Threading.Tasks; namespace Sandbox.RevealSDK @@ -18,6 +19,10 @@ public Task ResolveCredentialsAsync(RVDashboardDataSour { userCredential = new RVUsernamePasswordDataSourceCredential("username", "password", "domain"); } + else if (dataSource is RVSnowflakeDataSource) + { + userCredential = new RVUsernamePasswordDataSourceCredential("jberes", "revealUser2023"); + } return Task.FromResult(userCredential); } }