6
6
import org .apache .calcite .rel .type .RelProtoDataType ;
7
7
import org .apache .calcite .rel .type .RelDataTypeImpl ;
8
8
import org .apache .calcite .sql .SqlDialect ;
9
- import org .apache .calcite .sql .dialect .MysqlSqlDialect ;
9
+ import org .apache .calcite .sql .dialect .AnsiSqlDialect ;
10
10
11
11
import com .linkedin .hoptimator .catalog .Resource ;
12
12
import com .linkedin .hoptimator .catalog .HopTable ;
13
13
import com .linkedin .hoptimator .catalog .ScriptImplementor ;
14
14
15
15
import java .util .ArrayList ;
16
16
import java .util .List ;
17
- import java .util .Map ;
18
17
19
18
/**
20
19
* Calling convention which implements an SQL-based streaming data pipeline.
36
35
public interface PipelineRel extends RelNode {
37
36
38
37
Convention CONVENTION = new Convention .Impl ("PIPELINE" , PipelineRel .class );
39
- SqlDialect OUTPUT_DIALECT = MysqlSqlDialect .DEFAULT ; // closely resembles Flink SQL
40
- // TODO support alternative output dialects
41
38
42
39
void implement (Implementor implementor );
43
40
@@ -72,14 +69,14 @@ private void visit(RelNode input) {
72
69
}
73
70
74
71
/** Script ending in SELECT... */
75
- public String query () {
76
- return script .query (relNode ). sql ( OUTPUT_DIALECT ) ;
72
+ public ScriptImplementor query () {
73
+ return script .query (relNode );
77
74
}
78
75
79
76
/** Script ending in INSERT INTO ... */
80
- public String insertInto (HopTable sink ) {
77
+ public ScriptImplementor insertInto (HopTable sink ) {
81
78
return script .database (sink .database ()).with (sink )
82
- .insert (sink .database (), sink .name (), relNode ). sql ( OUTPUT_DIALECT ) ;
79
+ .insert (sink .database (), sink .name (), relNode );
83
80
}
84
81
85
82
/** Add any resources, SQL, DDL etc required to access the table. */
@@ -88,11 +85,15 @@ public void implement(HopTable table) {
88
85
table .resources ().forEach (x -> resource (x ));
89
86
}
90
87
91
- /** Combine SQL and any Resources into a Pipeline */
92
88
public Pipeline pipeline (HopTable sink ) {
89
+ return pipeline (sink , AnsiSqlDialect .DEFAULT );
90
+ }
91
+
92
+ /** Combine SQL and any Resources into a Pipeline */
93
+ public Pipeline pipeline (HopTable sink , SqlDialect sqlDialect ) {
93
94
List <Resource > resourcesAndJob = new ArrayList <>();
94
95
resourcesAndJob .addAll (resources );
95
- resourcesAndJob .add (new SqlJob (insertInto (sink )));
96
+ resourcesAndJob .add (new SqlJob (insertInto (sink ). sql ( sqlDialect ) ));
96
97
return new Pipeline (resourcesAndJob , rowType ());
97
98
}
98
99
}
0 commit comments