Skip to content

Commit 39422cb

Browse files
authored
Assert column names for partial views (#121)
1 parent 9455bc3 commit 39422cb

File tree

1 file changed

+7
-0
lines changed
  • hoptimator-util/src/main/java/com/linkedin/hoptimator/util/planner

1 file changed

+7
-0
lines changed

Diff for: hoptimator-util/src/main/java/com/linkedin/hoptimator/util/planner/PipelineRel.java

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ public Function<SqlDialect, String> sql(Properties connectionProperties) throws
141141
RelDataType targetRowType = sinkRowType;
142142
if (targetRowType == null) {
143143
targetRowType = query.getRowType();
144+
} else {
145+
// Assert target fields exist in the sink schema when the sink schema is known (partial view use case)
146+
for (String fieldName : targetFields.rightList()) {
147+
if (!targetRowType.getFieldNames().contains(fieldName)) {
148+
throw new IllegalArgumentException("Field " + fieldName + " not found in sink schema");
149+
}
150+
}
144151
}
145152
Map<String, String> sinkConfigs = ConnectionService.configure(sink, connectionProperties);
146153
script = script.database(sink.schema());

0 commit comments

Comments
 (0)