jackjlli commented on a change in pull request #6009: URL: https://github.com/apache/incubator-pinot/pull/6009#discussion_r488192591
########## File path: pinot-plugins/pinot-input-format/pinot-avro-base/src/main/java/org/apache/pinot/plugin/inputformat/avro/AvroIngestionSchemaValidator.java ########## @@ -111,36 +112,56 @@ private void validateSchemas() { } } if (nonNullSchema != null) { + avroColumnSchema = nonNullSchema; avroColumnType = nonNullSchema.getType(); } } - if (!fieldSpec.getDataType().name().equalsIgnoreCase(avroColumnType.toString())) { - _dataTypeMismatch.addMismatchReason(String - .format("The Pinot column: (%s: %s) doesn't match with the column (%s: %s) in input %s schema.", columnName, - fieldSpec.getDataType().name(), avroColumnSchema.getName(), avroColumnType.toString(), - getInputSchemaType())); - } - if (fieldSpec.isSingleValueField()) { + // check data type mismatch + if (!fieldSpec.getDataType().name().equalsIgnoreCase(avroColumnType.toString())) { + getDataTypeMismatchResult().addMismatchReason(String + .format("The Pinot column: (%s: %s) doesn't match with the column (%s: %s) in input %s schema.", columnName, + fieldSpec.getDataType().name(), avroColumnName, avroColumnType.toString(), + getInputSchemaType())); + } + // check single-value multi-value mismatch if (avroColumnType.ordinal() < org.apache.avro.Schema.Type.STRING.ordinal()) { // the column is a complex structure - _singleValueMultiValueFieldMismatch.addMismatchReason(String.format( - "The Pinot column: %s is 'single-value' column but the column: %s from input %s is 'multi-value' column.", - columnName, avroColumnSchema.getName(), getInputSchemaType())); + getSingleValueMultiValueFieldMismatchResult().addMismatchReason(String + .format( + "The Pinot column: %s is 'single-value' column but the column: %s from input %s is 'multi-value' column.", + columnName, avroColumnName, getInputSchemaType())); } } else { + // check data type mismatch Review comment: Done. ########## File path: pinot-plugins/pinot-input-format/pinot-avro-base/src/main/java/org/apache/pinot/plugin/inputformat/avro/AvroIngestionSchemaValidator.java ########## @@ -111,36 +112,56 @@ private void validateSchemas() { } } if (nonNullSchema != null) { + avroColumnSchema = nonNullSchema; avroColumnType = nonNullSchema.getType(); } } - if (!fieldSpec.getDataType().name().equalsIgnoreCase(avroColumnType.toString())) { - _dataTypeMismatch.addMismatchReason(String - .format("The Pinot column: (%s: %s) doesn't match with the column (%s: %s) in input %s schema.", columnName, - fieldSpec.getDataType().name(), avroColumnSchema.getName(), avroColumnType.toString(), - getInputSchemaType())); - } - if (fieldSpec.isSingleValueField()) { + // check data type mismatch + if (!fieldSpec.getDataType().name().equalsIgnoreCase(avroColumnType.toString())) { + getDataTypeMismatchResult().addMismatchReason(String + .format("The Pinot column: (%s: %s) doesn't match with the column (%s: %s) in input %s schema.", columnName, + fieldSpec.getDataType().name(), avroColumnName, avroColumnType.toString(), + getInputSchemaType())); + } + // check single-value multi-value mismatch if (avroColumnType.ordinal() < org.apache.avro.Schema.Type.STRING.ordinal()) { // the column is a complex structure - _singleValueMultiValueFieldMismatch.addMismatchReason(String.format( - "The Pinot column: %s is 'single-value' column but the column: %s from input %s is 'multi-value' column.", - columnName, avroColumnSchema.getName(), getInputSchemaType())); + getSingleValueMultiValueFieldMismatchResult().addMismatchReason(String + .format( + "The Pinot column: %s is 'single-value' column but the column: %s from input %s is 'multi-value' column.", + columnName, avroColumnName, getInputSchemaType())); } } else { + // check data type mismatch + FieldSpec.DataType dataTypeForMVColumn = AvroUtils.extractFieldDataType(avroColumnField); + if (fieldSpec.getDataType() != dataTypeForMVColumn) { + getDataTypeMismatchResult().addMismatchReason(String + .format("The Pinot column: (%s: %s) doesn't match with the column (%s: %s) in input %s schema.", + columnName, fieldSpec.getDataType().name(), avroColumnName, dataTypeForMVColumn.name(), + getInputSchemaType())); + } + // check single-value multi-value mismatch if (avroColumnType.ordinal() >= org.apache.avro.Schema.Type.STRING.ordinal()) { // the column is a complex structure - _singleValueMultiValueFieldMismatch.addMismatchReason(String.format( - "The Pinot column: %s is 'multi-value' column but the column: %s from input %s schema is 'single-value' column.", - columnName, avroColumnSchema.getName(), getInputSchemaType())); + getSingleValueMultiValueFieldMismatchResult().addMismatchReason(String + .format( + "The Pinot column: %s is 'multi-value' column but the column: %s from input %s schema is 'single-value' column.", + columnName, avroColumnName, getInputSchemaType())); } + // check multi-value column structure mismatch if (avroColumnType != org.apache.avro.Schema.Type.ARRAY) { // multi-value column should use array structure for now. - _multiValueStructureMismatch.addMismatchReason(String.format( + getMultiValueStructureMismatchResult().addMismatchReason(String.format( "The Pinot column: %s is 'multi-value' column but the column: %s from input %s schema is of '%s' type, which should have been of 'array' type.", - columnName, avroColumnSchema.getName(), getInputSchemaType(), avroColumnType.getName())); + columnName, avroColumnName, getInputSchemaType(), avroColumnType.getName())); + } else if (avroColumnSchema.getElementType().getType().ordinal() < org.apache.avro.Schema.Type.STRING Review comment: Done. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org