[ 
https://issues.apache.org/jira/browse/BEAM-3983?focusedWorklogId=96839&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-96839
 ]

ASF GitHub Bot logged work on BEAM-3983:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Apr/18 20:22
            Start Date: 30/Apr/18 20:22
    Worklog Time Spent: 10m 
      Work Description: kennknowles commented on a change in pull request 
#5220: [BEAM-3983][SQL] Add BigQuery table provider
URL: https://github.com/apache/beam/pull/5220#discussion_r185098999
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryTableProvider.java
 ##########
 @@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.beam.sdk.extensions.sql.meta.provider.bigquery;
+
+import static 
org.apache.beam.sdk.extensions.sql.meta.provider.MetaUtils.getRowTypeFromTable;
+
+import java.util.Collections;
+import java.util.List;
+import org.apache.beam.sdk.extensions.sql.BeamSqlTable;
+import org.apache.beam.sdk.extensions.sql.meta.Table;
+import org.apache.beam.sdk.extensions.sql.meta.provider.TableProvider;
+import org.apache.beam.sdk.schemas.Schema;
+
+/**
+ * BigQuery table provider.
+ *
+ * <p>A sample of text table is:
+ * <pre>{@code
+ * CREATE TABLE ORDERS(
+ *   ID INT COMMENT 'this is the primary key',
+ *   NAME VARCHAR(127) COMMENT 'this is the name'
+ * )
+ * TYPE 'bigquery'
+ * COMMENT 'this is the table orders'
+ * LOCATION '[PROJECT_ID]:[DATASET].[TABLE]'
+ * }</pre>
+ */
+public class BigQueryTableProvider implements TableProvider {
+
+  @Override public String getTableType() {
+    return "bigquery";
+  }
+
+  @Override public BeamSqlTable buildBeamSqlTable(Table table) {
+    Schema schema = getRowTypeFromTable(table);
+    String filePattern = table.getLocation();
+
+    return new BeamBigQueryTable(schema, filePattern);
+  }
+
+  @Override public void createTable(Table table) {
+    // empty
+  }
+
+  @Override public void dropTable(String tableName) {
+    // empty
 
 Review comment:
   <!--new_thread; commit:744fb5b4de53ad94916f80da2596c9b0b2b4c0a1; 
resolved:0-->
   A verbose comment here about our intentions might avoid anyone implementing 
this in a data lossy way later.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 96839)
    Time Spent: 12h 40m  (was: 12.5h)

> BigQuery writes from pure SQL
> -----------------------------
>
>                 Key: BEAM-3983
>                 URL: https://issues.apache.org/jira/browse/BEAM-3983
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Andrew Pilloud
>            Assignee: Andrew Pilloud
>            Priority: Major
>          Time Spent: 12h 40m
>  Remaining Estimate: 0h
>
> It would be nice if you could write to BigQuery in SQL without writing any 
> java code. For example:
> {code:java}
> INSERT INTO bigquery SELECT * FROM PCOLLECTION{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to