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

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

                Author: ASF GitHub Bot
            Created on: 06/Feb/19 18:34
            Start Date: 06/Feb/19 18:34
    Worklog Time Spent: 10m 
      Work Description: akedin commented on pull request #7745: [BEAM-5644] 
make Planner configurable
URL: https://github.com/apache/beam/pull/7745#discussion_r254393110
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamSqlEnv.java
 ##########
 @@ -174,8 +106,110 @@ public void executeDdl(String sqlStatement) throws 
ParseException {
   public String explain(String sqlString) throws ParseException {
     try {
       return RelOptUtil.toString(planner.convertToBeamRel(sqlString));
-    } catch (ValidationException | RelConversionException | SqlParseException 
e) {
+    } catch (Exception e) {
       throw new ParseException("Unable to parse statement", e);
     }
   }
+
+  /** BeamSqlEnv's Builder. */
+  public static class BeamSqlEnvBuilder {
+    private final JdbcConnection jdbcConnection;
+    private String plannerName = "CalcitePlanner";
+
+    public static BeamSqlEnvBuilder builder(TableProvider tableProvider) {
+      return new BeamSqlEnvBuilder(tableProvider);
+    }
+
+    private BeamSqlEnvBuilder(TableProvider tableProvider) {
+      jdbcConnection = JdbcDriver.connect(tableProvider);
 
 Review comment:
   I think that connection logic (and any other complicated logic) should live 
outside of the builder constructor or setter methods (e.g. applies to 
registering the udfs), either in `BeamSqlEnv` or at least in `build()`, this 
way you can pass around a not completely initialized builder to configure it, 
and then connect only when you know you have all the data. I.e. should be a 
simple data structure that only does complicated things in `build()` to pass 
them to the constructor of the outer class.
 
----------------------------------------------------------------
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: 195291)
    Time Spent: 6h 10m  (was: 6h)

> make Planner configurable 
> --------------------------
>
>                 Key: BEAM-5644
>                 URL: https://issues.apache.org/jira/browse/BEAM-5644
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>          Time Spent: 6h 10m
>  Remaining Estimate: 0h
>
> We can make planner configurable here: 
> [BeamQueryPlanner.java#L145|https://github.com/apache/beam/blob/master/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/BeamQueryPlanner.java#L145]
>  
> By doing so, we can have different planner implementation to support 
> different SQL dialect.



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

Reply via email to