Source:
<code>public static boolean validate(Schema schema) { for (FieldSpec fieldSpec : schema.getAllFieldSpecs()) { if (!fieldSpec.isVirtualColumn()) { String column = fieldSpec.getName(); String transformFunction = fieldSpec.getTransformFunction(); if (transformFunction != null) { ExpressionEvaluator expressionEvaluator = ExpressionEvaluatorFactory.getExpressionEvaluator(fieldSpec); if (expressionEvaluator != null) { List<String> arguments = expressionEvaluator.getArguments(); if (arguments.contains(column)) { LOGGER.error("The arguments of transform function: {}, should not contain the destination column: {}", transformFunction, column); return false; } } } else if (fieldSpec.getFieldType().equals(FieldSpec.FieldType.TIME)) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); <START> if (outgoingGranularitySpec != null && !incomingGranularitySpec.equals(outgoingGranularitySpec) <END> && incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName())) { LOGGER.error("Cannot convert from incoming field spec:{} to outgoing field spec:{} if name is the same", incomingGranularitySpec, outgoingGranularitySpec); return false; } } } } return true; }</code><technical_language>(nit) outgoingGranularitySpec null return incoming spec if outgoing is set</technical_language>

Target:
public static boolean validate(Schema schema) { try { for (FieldSpec fieldSpec : schema.getAllFieldSpecs()) { if (!fieldSpec.isVirtualColumn()) { String column = fieldSpec.getName(); String transformFunction = fieldSpec.getTransformFunction(); if (transformFunction != null) { ExpressionEvaluator expressionEvaluator = ExpressionEvaluatorFactory.getExpressionEvaluator(fieldSpec); if (expressionEvaluator != null) { List<String> arguments = expressionEvaluator.getArguments(); if (arguments.contains(column)) { LOGGER.error("The arguments of transform function: {}, should not contain the destination column: {}", transformFunction, column); return false; } } } else if (fieldSpec.getFieldType().equals(FieldSpec.FieldType.TIME)) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { if (incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName())) { LOGGER.error("Cannot convert from incoming field spec:{} to outgoing field spec:{} if name is the same", incomingGranularitySpec, outgoingGranularitySpec); return false; } else { if (!incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) || !outgoingGranularitySpec.getTimeFormat() .equals(TimeGranularitySpec.TimeFormat.EPOCH.toString())) { LOGGER.error( "When incoming and outgoing specs are different, cannot perform time conversion for time format other than EPOCH"); return false; } } } } } } } catch (Exception e) { LOGGER.error("Exception in validating schema {}", schema.getSchemaName(), e); return false; } return true; }