3
3
import java .util .ArrayList ;
4
4
import java .util .Collections ;
5
5
import java .util .List ;
6
+ import java .util .Properties ;
6
7
8
+ import org .apache .calcite .jdbc .CalciteSchema ;
7
9
import org .apache .calcite .schema .Schema ;
8
10
import org .apache .calcite .schema .SchemaPlus ;
9
11
import org .apache .calcite .schema .Table ;
10
12
import org .apache .calcite .schema .impl .AbstractSchema ;
11
- import org .apache .calcite .schema .impl .ViewTable ;
12
- import org .apache .calcite .schema .impl .ViewTableMacro ;
13
13
14
14
import io .kubernetes .client .openapi .models .V1ObjectMeta ;
15
15
16
16
import com .linkedin .hoptimator .Validated ;
17
17
import com .linkedin .hoptimator .Validator ;
18
18
import com .linkedin .hoptimator .jdbc .MaterializedViewTable ;
19
+ import com .linkedin .hoptimator .jdbc .schema .HoptimatorViewTableMacro ;
19
20
import com .linkedin .hoptimator .k8s .models .V1alpha1View ;
20
21
import com .linkedin .hoptimator .k8s .models .V1alpha1ViewList ;
21
22
import com .linkedin .hoptimator .k8s .models .V1alpha1ViewSpec ;
@@ -75,7 +76,7 @@ public K8sViewTable(K8sContext context) {
75
76
super (context , K8sApiEndpoints .VIEWS , Row .class );
76
77
}
77
78
78
- public void addViews (SchemaPlus parentSchema ) {
79
+ public void addViews (SchemaPlus parentSchema , Properties connectionProperties ) {
79
80
for (Row row : rows ()) {
80
81
81
82
// build schema path, filling in any missing schemas
@@ -88,7 +89,7 @@ public void addViews(SchemaPlus parentSchema) {
88
89
}
89
90
schema = next ;
90
91
}
91
- schema .add (row .viewName (), makeView (schema , row ));
92
+ schema .add (row .viewName (), makeView (schema , row , connectionProperties ));
92
93
}
93
94
}
94
95
@@ -107,12 +108,13 @@ public void remove(String name) {
107
108
rows ().remove (find (name ));
108
109
}
109
110
110
- private Table makeView (SchemaPlus parentSchema , Row row ) {
111
- ViewTableMacro viewTableMacro = ViewTable .viewMacro (parentSchema , row .SQL , row .schemaPath (), row .viewPath (), false );
111
+ private Table makeView (SchemaPlus parentSchema , Row row , Properties connectionProperties ) {
112
+ HoptimatorViewTableMacro viewTableMacro = new HoptimatorViewTableMacro (CalciteSchema .from (parentSchema ), row .SQL ,
113
+ row .schemaPath (), row .viewPath (), false );
112
114
if (row .MATERIALIZED ) {
113
- return new MaterializedViewTable (viewTableMacro );
115
+ return new MaterializedViewTable (viewTableMacro , connectionProperties );
114
116
} else {
115
- return viewTableMacro .apply (Collections . emptyList () );
117
+ return viewTableMacro .apply (connectionProperties );
116
118
}
117
119
}
118
120
0 commit comments