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

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

                Author: ASF GitHub Bot
            Created on: 08/May/18 15:33
            Start Date: 08/May/18 15:33
    Worklog Time Spent: 10m 
      Work Description: kennknowles commented on a change in pull request 
#5253: [BEAM-4162][SQL] Wire up PubsubIO to SQL
URL: https://github.com/apache/beam/pull/5253#discussion_r186771226
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/BeamSqlCli.java
 ##########
 @@ -74,22 +75,31 @@ public String explainQuery(String sqlString) throws 
Exception {
   /**
    * Executes the given sql.
    */
-  public void execute(String sqlString) throws Exception {
+  public Optional<PCollection<Row>> execute(String sqlString) throws Exception 
{
     BeamSqlParser parser = new BeamSqlParser(sqlString);
     SqlNode sqlNode = parser.impl().parseSqlStmtEof();
 
     if (sqlNode instanceof SqlCreateTable) {
       handleCreateTable((SqlCreateTable) sqlNode, metaStore);
-    } else if (sqlNode instanceof SqlDropTable) {
+      return Optional.empty();
+    }
+
+    if (sqlNode instanceof SqlDropTable) {
       handleDropTable((SqlDropTable) sqlNode);
-    } else {
-      PipelineOptions options = PipelineOptionsFactory.fromArgs(new String[] 
{}).withValidation()
-          .as(PipelineOptions.class);
-      options.setJobName("BeamPlanCreator");
-      Pipeline pipeline = Pipeline.create(options);
-      compilePipeline(sqlString, pipeline, env);
-      pipeline.run();
+      return Optional.empty();
     }
+
+    DirectOptions options =
+        PipelineOptionsFactory
+            .fromArgs()
+            .withValidation()
+            .as(DirectOptions.class);
+
+    options.setJobName("BeamPlanCreator");
+    Pipeline pipeline = Pipeline.create(options);
+    PCollection<Row> result = env.getPlanner().compileBeamPipeline(sqlString, 
pipeline, env);
+    pipeline.run();
+    return Optional.of(result);
 
 Review comment:
   <!--new_thread; commit:bd86c968878f080c2d774f7485ae76ccc0534792; 
resolved:0-->
   This is strange. A PCollection is really just a token passed around within a 
pipeline. Once the pipeline is launched, it is immutable and not very useful.

----------------------------------------------------------------
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: 99576)
    Time Spent: 4h  (was: 3h 50m)

> Wire up PubsubIO+JSON to Beam SQL
> ---------------------------------
>
>                 Key: BEAM-4162
>                 URL: https://issues.apache.org/jira/browse/BEAM-4162
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Anton Kedin
>            Assignee: Anton Kedin
>            Priority: Major
>          Time Spent: 4h
>  Remaining Estimate: 0h
>
> Read JSON messages from Pubsub, convert them to Rows (BEAM-4160), wire up to 
> Beam SQL.
>  
> Use publication time as event timestamp



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

Reply via email to