Exemple #1
0
        public void TestListTables()
        {
            string datasetId  = "datasetForTestListTables";
            string newTableId = "tableForTestListTables";

            CreateDataset(datasetId, _client);
            CreateTable(datasetId, newTableId, _client);
            // [START list_tables]
            var tables = _client.ListTables(datasetId).ToList();

            // [END list_tables]
            Assert.False(tables.Count() == 0);
            DeleteTable(datasetId, newTableId, _client);
            DeleteDataset(datasetId, _client);
        }
        public void ListTables()
        {
            string projectId = _fixture.ProjectId;
            string datasetId = _fixture.GameDatasetId;

            // Snippet: ListTables(string,ListTablesOptions)
            BigqueryClient client = BigqueryClient.Create(projectId);
            var            tables = client.ListTables(datasetId).ToList();

            foreach (var table in tables)
            {
                Console.WriteLine(table.FullyQualifiedId);
            }
            // End snippet

            var ids = tables.Select(ds => ds.Reference.TableId).ToList();

            Assert.Contains(_fixture.HistoryTableId, ids);
        }
        public void CreateTable()
        {
            string projectId = _fixture.ProjectId;
            string datasetId = _fixture.GameDatasetId;
            string tableId   = Guid.NewGuid().ToString().Replace("-", "_");

            // Snippet: CreateTable(string,string,*,*)
            BigqueryClient client = BigqueryClient.Create(projectId);
            TableSchema    schema = new TableSchemaBuilder
            {
                { "from_player", BigqueryDbType.String },
                { "to_player", BigqueryDbType.String },
                { "message", BigqueryDbType.String }
            }.Build();
            BigqueryTable table = client.CreateTable(datasetId, tableId, schema);
            // Now populate the table with data...
            // End snippet

            var tables = client.ListTables(datasetId);
            var ids    = tables.Select(ds => ds.Reference.TableId).ToList();

            Assert.Contains(tableId, ids);
        }