private void validateOutput(RelRoot relRoot, RelSchemaProvider outputRelSchemaProvider)
      throws SamzaSqlValidatorException {
    LogicalProject project = (LogicalProject) relRoot.rel;

    RelRecordType projectRecord = (RelRecordType) project.getRowType();
    RelRecordType outputRecord = (RelRecordType) QueryPlanner.getSourceRelSchema(outputRelSchemaProvider,
        new RelSchemaConverter());

    // Handle any DELETE ops.
    if (projectRecord.getFieldList().stream().anyMatch(f -> f.getName().equalsIgnoreCase(SamzaSqlRelMessage.OP_NAME))) {
      validateDeleteOp(relRoot);
      return;
    }

    // Get Samza Sql schema along with Calcite schema. The reason is that the Calcite schema does not have a way
    // to represent optional fields while Samza Sql schema can represent optional fields. This is the reason that
    // we use SqlSchema in validating output.
    SqlSchema outputSqlSchema = QueryPlanner.getSourceSqlSchema(outputRelSchemaProvider);

    validateOutputRecords(outputSqlSchema, outputRecord, projectRecord, outputRelSchemaProvider);
    LOG.info("Samza Sql Validation finished successfully.");
  }
Determine if validation needs to be done on Calcite plan based on the schema provider and schema converter.
@param relRoot
@param sink
@param outputSchemaProvider
@param ouputRelSchemaConverter
@return if the validation needs to be skipped
samza-sql/src/main/java/org/apache/samza/sql/planner/SamzaSqlValidator.java