From 14dd37b61fcd22b78684151c04bc45b7ece54991 Mon Sep 17 00:00:00 2001 From: Viktor Date: Fri, 6 Dec 2024 15:59:08 +0700 Subject: [PATCH 1/5] Update Snowflake datasource / datasource item features, test and examples --- .../DashboardCreators/SnowFlakeDashboard.cs | 57 +++++++++++ e2e/Sandbox/MainWindow.xaml.cs | 4 +- e2e/Sandbox/Reveal/AuthenticationProvider.cs | 5 + .../SnowflakeDataSourceItemFixture.cs | 96 +++++++++++++++---- .../DataSources/SnowflakeDataSourceFixture.cs | 57 ++++++++++- .../Data/TableDataSourceltemFixture.cs | 20 ++++ .../Data/DataSources/SnowflakeDataSource.cs | 2 +- .../Data/TableDataSourceItem.cs | 7 ++ 8 files changed, 223 insertions(+), 25 deletions(-) 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..6677250e 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("snow-flake-username", "snow-flake-password"); + } return Task.FromResult(userCredential); } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 20d8b767..971d0d0c 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -1,4 +1,6 @@ -using Reveal.Sdk.Dom.Core.Extensions; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Constants; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -7,49 +9,107 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems public class SnowflakeDataSourceItemFixture { [Theory] - [InlineData("Test Item")] - [InlineData(null)] - public void Constructor_SetsTitleAndDataSource_WhenCalled(string title) + [InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")] + [InlineData(null, "DSI Title", "DSI Title", "DSI Title")] + public void Constructor_CreateSnowFlakeDSI_WithTitleAndDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle) { // Arrange - var dataSource = new SnowflakeDataSource(); + var dataSource = new DataSource() { Title = dsTitle }; // Act - var item = new SnowflakeDataSourceItem(title, dataSource); + var item = new SnowflakeDataSourceItem(dsiTitle, dataSource); // Assert - Assert.Equal(title, item.Title); - Assert.Equal(dataSource, item.DataSource); + Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName); + Assert.Equal(expectedDSTitle, item.DataSource.Title); + Assert.Equal(dataSource.Id, item.DataSource.Id); + Assert.Equal(dataSource.Id, item.DataSourceId); + Assert.IsType(item.DataSource); + Assert.NotSame(dataSource, item.DataSource); + Assert.Equal(expectedDSITitle, item.Title); } [Theory] - [InlineData("Test Item")] - [InlineData(null)] - public void Constructor_SetsTitleAndDataSource_WhenConstructedWithGenericDataSource(string title) + [InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")] + [InlineData(null, "DSI Title", "DSI Title", "DSI Title")] + public void Constructor_CreateSnowFlakeDSI_WithTitleAndSnowFlakeDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle) { // Arrange - var dataSource = new DataSource(); + var dataSource = new SnowflakeDataSource() { Title = dsTitle }; // Act - var item = new SnowflakeDataSourceItem(title, dataSource); + var item = new SnowflakeDataSourceItem(dsiTitle, dataSource); // Assert - Assert.Equal(title, item.Title); + Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName); + Assert.Equal(expectedDSTitle, item.DataSource.Title); + Assert.Equal(dataSource.Id, item.DataSource.Id); + Assert.Equal(dataSource.Id, item.DataSourceId); Assert.IsType(item.DataSource); + Assert.Same(dataSource, item.DataSource); + Assert.Equal(expectedDSITitle, item.Title); } [Fact] - public void ProcessDataOnServer_ShouldSetAndGetValue_WithInputs() + public void GetProcessDataOnServer_ReturnSameValue_AfterSet() { // Arrange var item = new SnowflakeDataSourceItem("Test Item", new SnowflakeDataSource()); + var expectedProcessDataOnServer = true; // Act - item.ProcessDataOnServer = true; + item.ProcessDataOnServer = expectedProcessDataOnServer; // Assert - Assert.True(item.ProcessDataOnServer); - Assert.True(item.Properties.GetValue("ServerAggregation")); + Assert.Equal(expectedProcessDataOnServer, item.ProcessDataOnServer); + Assert.Equal(expectedProcessDataOnServer, item.Properties.GetValue("ServerAggregation")); + } + + [Fact] + public void ToJsonString_CreatesFormattedJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceItemType"", + ""Id"": ""a60ab508-0ed4-46e4-8d90-c3a9c09c29b8"", + ""Title"": ""SnowFlake DSI"", + ""DataSourceId"": ""snowflake_ds"", + ""HasTabularData"": true, + ""HasAsset"": false, + ""Properties"": { + ""ServerAggregation"": true, + ""Table"": ""CALL_CENTER"", + ""Schema"": ""TPCDS_SF100TCL"" + }, + ""Parameters"": { + ""RPCustomQuery"": ""Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER"" + } + }"; + + var dataSource = new SnowflakeDataSource() + { + Id = "snowflake_ds", + }; + var dataSourceItem = new SnowflakeDataSourceItem("SnowFlake DSI", dataSource) + { + Id = "a60ab508-0ed4-46e4-8d90-c3a9c09c29b8", + HasTabularData = true, + HasAsset = false, + ProcessDataOnServer = true, + Table = "CALL_CENTER", + Schema = "TPCDS_SF100TCL", + CustomQuery = "Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER", + }; + + var expectedJObject = JObject.Parse(expectedJson); + + // Act + var json = dataSourceItem.ToJsonString(); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs index 1803b905..ff934fcd 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs @@ -1,4 +1,5 @@ -using Reveal.Sdk.Dom.Core.Extensions; +using Newtonsoft.Json.Linq; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -7,7 +8,7 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSources public class SnowflakeDataSourceFixture { [Fact] - public void SnowflakeDataSource_ShouldSetProviderToSnowflake() + public void Constructor_SetDefaultProvider_WithoutParameter() { // Act var dataSource = new SnowflakeDataSource(); @@ -19,7 +20,7 @@ public void SnowflakeDataSource_ShouldSetProviderToSnowflake() [Theory] [InlineData("testAccount")] [InlineData(null)] - public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account) + public void GetAccount_ReturnSameValue_AfterSetAccount(string account) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -35,7 +36,7 @@ public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account) [Theory] [InlineData("testRole")] [InlineData(null)] - public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role) + public void GetRole_ReturnSameValue_AfterSetRole(string role) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -51,7 +52,7 @@ public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role) [Theory] [InlineData("testWarehouse")] [InlineData(null)] - public void Warehouse_ShouldSetAndGetValue_WithDifferentInputs(string warehouse) + public void SetWarehouse_ReturnSameValue_AfterSetWarehouse(string warehouse) { // Arrange var dataSource = new SnowflakeDataSource(); @@ -63,5 +64,51 @@ public void Warehouse_ShouldSetAndGetValue_WithDifferentInputs(string warehouse) Assert.Equal(warehouse, dataSource.Warehouse); Assert.Equal(warehouse, dataSource.Properties.GetValue("Warehouse")); } + + [Fact] + public void ToJsonString_CreatesFormattedJson_NoConditions() + { + // Arrange + var expectedJson = @"{ + ""_type"": ""DataSourceType"", + ""Id"": ""snowflake_ds"", + ""Provider"": ""SNOWFLAKE"", + ""Description"": ""Snowflake TEST"", + ""Subtitle"": ""Snowflake TEST Subtitle"", + ""Properties"": { + ""ServerAggregationDefault"": true, + ""ServerAggregationReadOnly"": false, + ""Host"": ""gpiskyj-al16914.snowflakecomputing.com"", + ""Database"": ""SNOWFLAKE_SAMPLE_DATA"", + ""Account"": ""pqwkobs-xb90908"", + ""Warehouse"": ""COMPUTE_WH"", + ""Schema"": ""TPCDS_SF100TCL"" + }, + //""Settings"": {} // TODO: Update to check settings fields after Postgresql PR is merged + }"; + + var dataSource = new SnowflakeDataSource() + { + Id = "snowflake_ds", + Title = "Snowflake TEST", + Subtitle = "Snowflake TEST Subtitle", + ProcessDataOnServerDefaultValue = true, + ProcessDataOnServerReadOnly = false, + Host = "gpiskyj-al16914.snowflakecomputing.com", + Database = "SNOWFLAKE_SAMPLE_DATA", + Account = "pqwkobs-xb90908", + Warehouse = "COMPUTE_WH", + Schema = "TPCDS_SF100TCL", + }; + var expectedJObject = JObject.Parse(expectedJson); + + // Act + var json = dataSource.ToJsonString(); + var actualJObject = JObject.Parse(json); + + // Assert + Assert.Equal(expectedJObject, actualJObject); + + } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs index a357293e..e4c42087 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs @@ -1,4 +1,5 @@ using Moq; +using Reveal.Sdk.Dom.Core.Extensions; using Reveal.Sdk.Dom.Data; using Xunit; @@ -39,6 +40,25 @@ public void GetTable_ReturnSameValue_WithSetValue() // Assert Assert.Equal(expectedTable, tableDataSourceItem.Table); + Assert.Equal(expectedTable, tableDataSourceItem.Properties.GetValue("Table")); + } + + [Fact] + public void GetCustomQuery_ReturnSameValue_WithSetValue() + { + // Arrange + var title = "Title"; + var dataSource = new DataSource(); + var mock = new Mock(title, dataSource); + var tableDataSourceItem = mock.Object; + var expectedCustomQuery = "Select FieldA, FieldB from SampleTable;"; + + // Act + tableDataSourceItem.CustomQuery = expectedCustomQuery; + + // Assert + Assert.Equal(expectedCustomQuery, tableDataSourceItem.CustomQuery); + Assert.Equal(expectedCustomQuery, tableDataSourceItem.Parameters.GetValue("RPCustomQuery")); } } } diff --git a/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs b/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs index a9679506..b2857916 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs @@ -3,7 +3,7 @@ namespace Reveal.Sdk.Dom.Data { - public class SnowflakeDataSource : ProcessDataSource + public class SnowflakeDataSource : SchemaDataSource { public SnowflakeDataSource() { diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index c7f5ab61..4505a039 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -15,5 +15,12 @@ public string Table get => Properties.GetValue("Table"); set => Properties.SetItem("Table", value); } + + [JsonIgnore] + public string CustomQuery + { + get => Parameters.GetValue("RPCustomQuery"); + set => Parameters.SetItem("RPCustomQuery", value); + } } } From 0cc8f896e2f923d2f5039d6fef97a6bdd258ecb4 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 14:46:00 +0700 Subject: [PATCH 2/5] Remove CustomQuery field --- .../DashboardCreators/SnowFlakeDashboard.cs | 6 ------ .../SnowflakeDataSourceItemFixture.cs | 5 +---- .../Data/TableDataSourceltemFixture.cs | 18 ------------------ src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs | 6 ------ 4 files changed, 1 insertion(+), 34 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs index 4c53e9fd..797bb736 100644 --- a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -2,11 +2,7 @@ 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 { @@ -25,7 +21,6 @@ public RdashDocument CreateDashboard() DefaultRefreshRate = "120", Host = "gpiskyj-al16914.snowflakecomputing.com", Database = "SNOWFLAKE_SAMPLE_DATA", - //Role Warehouse = "COMPUTE_WH", Schema = "TPCDS_SF100TCL" }; @@ -35,7 +30,6 @@ public RdashDocument CreateDashboard() 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", diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 971d0d0c..617074f5 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -81,9 +81,7 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() ""Table"": ""CALL_CENTER"", ""Schema"": ""TPCDS_SF100TCL"" }, - ""Parameters"": { - ""RPCustomQuery"": ""Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER"" - } + ""Parameters"": {} }"; var dataSource = new SnowflakeDataSource() @@ -98,7 +96,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() ProcessDataOnServer = true, Table = "CALL_CENTER", Schema = "TPCDS_SF100TCL", - CustomQuery = "Select CC_CALL_CENTER_ID, CC_CALL_CENTER_SK from CALL_CENTER", }; var expectedJObject = JObject.Parse(expectedJson); diff --git a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs index e4c42087..75654770 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs @@ -42,23 +42,5 @@ public void GetTable_ReturnSameValue_WithSetValue() Assert.Equal(expectedTable, tableDataSourceItem.Table); Assert.Equal(expectedTable, tableDataSourceItem.Properties.GetValue("Table")); } - - [Fact] - public void GetCustomQuery_ReturnSameValue_WithSetValue() - { - // Arrange - var title = "Title"; - var dataSource = new DataSource(); - var mock = new Mock(title, dataSource); - var tableDataSourceItem = mock.Object; - var expectedCustomQuery = "Select FieldA, FieldB from SampleTable;"; - - // Act - tableDataSourceItem.CustomQuery = expectedCustomQuery; - - // Assert - Assert.Equal(expectedCustomQuery, tableDataSourceItem.CustomQuery); - Assert.Equal(expectedCustomQuery, tableDataSourceItem.Parameters.GetValue("RPCustomQuery")); - } } } diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index 4505a039..63879125 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -16,11 +16,5 @@ public string Table set => Properties.SetItem("Table", value); } - [JsonIgnore] - public string CustomQuery - { - get => Parameters.GetValue("RPCustomQuery"); - set => Parameters.SetItem("RPCustomQuery", value); - } } } From e6afff28f7668197e63ffe71c73845db0bc3ca84 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 15:01:04 +0700 Subject: [PATCH 3/5] Update namespace name --- e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs | 5 ++--- e2e/Sandbox/MainWindow.xaml.cs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs index 797bb736..a54c8b70 100644 --- a/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/SnowFlakeDashboard.cs @@ -1,14 +1,13 @@ using Reveal.Sdk.Dom; using Reveal.Sdk.Dom.Data; using Reveal.Sdk.Dom.Visualizations; -using Sandbox.DashboardFactories; using System.Collections.Generic; -namespace Sandbox.DashboardCreators +namespace Sandbox.DashboardFactories { internal class SnowflakeDashboard : IDashboardCreator { - public string Name => "Snowflake Dashboard"; + public string Name => "Snowflake Data Source"; public RdashDocument CreateDashboard() { diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index b1f73518..785a7055 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -22,7 +22,6 @@ 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,8 +50,8 @@ public partial class MainWindow : Window new MarketingDashboard(), new RestDataSourceDashboard(), new SalesDashboard(), - new SqlServerDataSourceDashboards(), new SnowflakeDashboard(), + new SqlServerDataSourceDashboards(), }; public MainWindow() From 8a08ebeabd047ce57ca7c08507c0bec4561c7786 Mon Sep 17 00:00:00 2001 From: Viktor Date: Tue, 10 Dec 2024 16:40:16 +0700 Subject: [PATCH 4/5] Remvove uneeded changes --- src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs index 63879125..c7f5ab61 100644 --- a/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs @@ -15,6 +15,5 @@ public string Table get => Properties.GetValue("Table"); set => Properties.SetItem("Table", value); } - } } From 8b92aff8ef8568ade53aafe9d134bea092002ff2 Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 14:32:05 +0700 Subject: [PATCH 5/5] Fix failed unit tests --- .../SnowflakeDataSourceItemFixture.cs | 31 +++++++-------- .../DataSources/SnowflakeDataSourceFixture.cs | 39 ++++++++++--------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs index 617074f5..9763900d 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/SnowflakeDataSourceItemFixture.cs @@ -69,21 +69,22 @@ public void GetProcessDataOnServer_ReturnSameValue_AfterSet() public void ToJsonString_CreatesFormattedJson_NoConditions() { // Arrange - var expectedJson = @"{ - ""_type"": ""DataSourceItemType"", - ""Id"": ""a60ab508-0ed4-46e4-8d90-c3a9c09c29b8"", - ""Title"": ""SnowFlake DSI"", - ""DataSourceId"": ""snowflake_ds"", - ""HasTabularData"": true, - ""HasAsset"": false, - ""Properties"": { - ""ServerAggregation"": true, - ""Table"": ""CALL_CENTER"", - ""Schema"": ""TPCDS_SF100TCL"" + var expectedJson = """ + { + "_type": "DataSourceItemType", + "Id": "a60ab508-0ed4-46e4-8d90-c3a9c09c29b8", + "Title": "SnowFlake DSI", + "DataSourceId": "snowflake_ds", + "HasTabularData": true, + "HasAsset": false, + "Properties": { + "ServerAggregation": true, + "Table": "CALL_CENTER", + "Schema": "TPCDS_SF100TCL" }, - ""Parameters"": {} - }"; - + "Parameters": {} + } + """; var dataSource = new SnowflakeDataSource() { Id = "snowflake_ds", @@ -97,7 +98,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() Table = "CALL_CENTER", Schema = "TPCDS_SF100TCL", }; - var expectedJObject = JObject.Parse(expectedJson); // Act @@ -106,7 +106,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() // Assert Assert.Equal(expectedJObject, actualJObject); - } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs index ff934fcd..4680fd0a 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/SnowflakeDataSourceFixture.cs @@ -69,24 +69,27 @@ public void SetWarehouse_ReturnSameValue_AfterSetWarehouse(string warehouse) public void ToJsonString_CreatesFormattedJson_NoConditions() { // Arrange - var expectedJson = @"{ - ""_type"": ""DataSourceType"", - ""Id"": ""snowflake_ds"", - ""Provider"": ""SNOWFLAKE"", - ""Description"": ""Snowflake TEST"", - ""Subtitle"": ""Snowflake TEST Subtitle"", - ""Properties"": { - ""ServerAggregationDefault"": true, - ""ServerAggregationReadOnly"": false, - ""Host"": ""gpiskyj-al16914.snowflakecomputing.com"", - ""Database"": ""SNOWFLAKE_SAMPLE_DATA"", - ""Account"": ""pqwkobs-xb90908"", - ""Warehouse"": ""COMPUTE_WH"", - ""Schema"": ""TPCDS_SF100TCL"" + var expectedJson = """ + { + "_type": "DataSourceType", + "Id": "snowflake_ds", + "Provider": "SNOWFLAKE", + "Description": "Snowflake TEST", + "Subtitle": "Snowflake TEST Subtitle", + "Properties": { + "ServerAggregationDefault": true, + "ServerAggregationReadOnly": false, + "Host": "gpiskyj-al16914.snowflakecomputing.com", + "Database": "SNOWFLAKE_SAMPLE_DATA", + "Account": "pqwkobs-xb90908", + "Warehouse": "COMPUTE_WH", + "Schema": "TPCDS_SF100TCL" }, - //""Settings"": {} // TODO: Update to check settings fields after Postgresql PR is merged - }"; - + "Settings": { + "DefaultRefreshRate": 180 + } + } + """; var dataSource = new SnowflakeDataSource() { Id = "snowflake_ds", @@ -99,6 +102,7 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() Account = "pqwkobs-xb90908", Warehouse = "COMPUTE_WH", Schema = "TPCDS_SF100TCL", + DefaultRefreshRate = "180" }; var expectedJObject = JObject.Parse(expectedJson); @@ -108,7 +112,6 @@ public void ToJsonString_CreatesFormattedJson_NoConditions() // Assert Assert.Equal(expectedJObject, actualJObject); - } } }