public void ListTablesConversion() { var listResource = new TableList.TablesData { FriendlyName = "friendly name", Id = "id", Kind = "Table", Labels = new Dictionary <string, string> { { "x", "y" } }, TableReference = new TableReference { DatasetId = "dataset", TableId = "id", ProjectId = "project" }, TimePartitioning = new TimePartitioning { ExpirationMs = 10000, Type = "DAY" }, Type = "VIEW", View = new TableList.TablesData.ViewData { UseLegacySql = true } }; var tableResource = BigQueryClientImpl.TablePageManager.ConvertResource(listResource); Assert.Equal("friendly name", tableResource.FriendlyName); Assert.Equal("id", tableResource.Id); Assert.Equal("Table", tableResource.Kind); Assert.Equal("y", tableResource.Labels["x"]); Assert.Same(listResource.TableReference, tableResource.TableReference); Assert.Equal("VIEW", tableResource.Type); Assert.True(tableResource.View.UseLegacySql); }
internal BigqueryTable(BigqueryClient client, TableList.TablesData resource) : this(client, new Table { TableReference = resource.TableReference, FriendlyName = resource.FriendlyName, Id = resource.Id, Kind = resource.Kind }) { }
// Visible for testing /// <summary> /// Converts from the list representation of a table to the get/update/patch one, as far as possible. /// </summary> internal static Table ConvertResource(TableList.TablesData resource) => new Table { FriendlyName = resource.FriendlyName, Id = resource.Id, Kind = resource.Kind, Labels = resource.Labels, TimePartitioning = resource.TimePartitioning, TableReference = resource.TableReference, Type = resource.Type, View = resource.View == null ? null : new ViewDefinition { UseLegacySql = resource.View.UseLegacySql } };
public void ListTablesConversion() { var listResource = new TableList.TablesData { FriendlyName = "friendly name", Id = "id", Kind = "Table", Labels = new Dictionary <string, string> { { "x", "y" } }, TableReference = new TableReference { DatasetId = "dataset", TableId = "id", ProjectId = "project" }, TimePartitioning = new TimePartitioning { ExpirationMs = 10000, Type = "DAY" }, Type = "VIEW", View = new TableList.TablesData.ViewData { UseLegacySql = true }, Clustering = new Clustering { Fields = new[] { "ClusterCol1", "ClusterCol2" } }, CreationTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds, ExpirationTime = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds }; var tableResource = BigQueryClientImpl.TablePageManager.ConvertResource(listResource); Assert.Equal("friendly name", tableResource.FriendlyName); Assert.Equal("id", tableResource.Id); Assert.Equal("Table", tableResource.Kind); Assert.Equal("y", tableResource.Labels["x"]); Assert.Same(listResource.TableReference, tableResource.TableReference); Assert.Equal("VIEW", tableResource.Type); Assert.True(tableResource.View.UseLegacySql); Assert.Equal(listResource.Clustering.Fields, tableResource.Clustering.Fields); Assert.Equal(listResource.CreationTime, tableResource.CreationTime); Assert.Equal(listResource.ExpirationTime, tableResource.ExpirationTime); }