2016-03-02 61 views
3

嗨,我可以这样使用SQL的旧表在MSSQL或Oracle创建表的表:创建从选择的BigQuery

Select * into new_table from old_table; 

是否有可能做到这一点BigQuery中?在控制台中输入以下内容时出现错误:“错误:在第2行第1列遇到”“INTO”“INTO”“正在等待:”。

我有一个内联用户定义函数的选择。我喜欢将这个选择的输出存储在一个单独的表中。

+0

它是一个很好的做法(你可以definitelly做到这一点)回答你自己的问题,如果你觉得你有一个好(如在这种情况下)。总体常识规则是单独回答问题 –

+0

是的你是对的:)。 –

回答

3

你不能使用into,但你可以点击“显示选项”并在那里选择一个表格。

+0

Thx伙计,有没有办法通过.net api做到这一点? –

+1

是的。我对.net api不熟悉,但可以通过设置DestinationTable属性来实现。看看这里:https://developers.google.com/resources/api-library/documentation/bigquery/v2/csharp/latest/classGoogle_1_1Apis_1_1Bigquery_1_1v2_1_1Data_1_1JobConfigurationQuery.html#ab086707c20c7703b9c0a3d113fc71aa7 – oulenz

2

对于那些谁是寻找在C#在.NET客户端API(用于提示THX oulenz)的解决方案:

public void ExecQueryIntoTable(string projectId, string dataSetId, string destinationTable, string query) 
    { 
     try 
     { 
      JobsResource jobResource = bigqueryService.Jobs; 
      Job theJob = new Job(); 
      theJob.Configuration = new JobConfiguration() 
      { 
       Query = new JobConfigurationQuery() 
       { 
        AllowLargeResults = true, 
        CreateDisposition = "CREATE_IF_NEEDED", 
        DefaultDataset = new DatasetReference() { ProjectId = projectId, DatasetId = dataSetId}, 
        MaximumBillingTier = 100, 
        DestinationTable = new TableReference() { ProjectId = projectId, DatasetId = dataSetId, TableId = destinationTable }, 
        Query = query 
       } 
      }; 

      var result = jobResource.Insert(theJob, projectId).Execute(); 
     } 
     catch (Exception ex) 
     { 
      log.Fatal(ex, ex.Message + ", StackTrace: " + ex.StackTrace); 
      throw; 
     } 
    } 
+0

我不知道以上是否正确。 当使用大表时,上述jobresource.Insert ...可能没有完成(它异步运行,所以我需要检查状态,或同步运行) - 我该怎么做? – Eitan