@Test public void testValidateTimeFieldSpec() { Schema pinotSchema; pinotSchema = new Schema.SchemaBuilder() .addTime(new TimeGranularitySpec(DataType.LONG, TimeUnit.MILLISECONDS, "time"), new TimeGranularitySpec(DataType.INT, TimeUnit.DAYS, "time")).build(); checkValidationFails(pinotSchema); pinotSchema = new Schema.SchemaBuilder() .addTime(new TimeGranularitySpec(DataType.LONG, TimeUnit.MILLISECONDS, "incoming"), new TimeGranularitySpec(DataType.INT, TimeUnit.DAYS, TimeGranularitySpec.TimeFormat.SIMPLE_DATE_FORMAT.toString(), "outgoing")).build(); checkValidationFails(pinotSchema); pinotSchema = new Schema.SchemaBuilder() .addTime(new TimeGranularitySpec(DataType.LONG, TimeUnit.MILLISECONDS, "incoming"), new TimeGranularitySpec(DataType.INT, TimeUnit.DAYS, "outgoing")).build(); SchemaUtils.validate(pinotSchema); }
private static void validateTimeFieldSpec(FieldSpec fieldSpec) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { Preconditions.checkState(!incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName()), "Cannot convert from incoming field spec %s to outgoing field spec %s if name is the same", incomingGranularitySpec, outgoingGranularitySpec); Preconditions.checkState( incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) && outgoingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()), "Cannot perform time conversion for time format other than EPOCH. TimeFieldSpec: %s", fieldSpec); } }
SchemaUtils { private static void validateTimeFieldSpec(FieldSpec fieldSpec) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { Preconditions.checkState(!incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName()), "Cannot convert from incoming field spec %s to outgoing field spec %s if name is the same", incomingGranularitySpec, outgoingGranularitySpec); Preconditions.checkState( incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) && outgoingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()), "Cannot perform time conversion for time format other than EPOCH. TimeFieldSpec: %s", fieldSpec); } } }
SchemaUtils { private static void validateTimeFieldSpec(FieldSpec fieldSpec) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { Preconditions.checkState(!incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName()), "Cannot convert from incoming field spec %s to outgoing field spec %s if name is the same", incomingGranularitySpec, outgoingGranularitySpec); Preconditions.checkState( incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) && outgoingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()), "Cannot perform time conversion for time format other than EPOCH. TimeFieldSpec: %s", fieldSpec); } }  }
SchemaUtils { private static void validateTimeFieldSpec(FieldSpec fieldSpec) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { Preconditions.checkState(!incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName()), "Cannot convert from incoming field spec %s to outgoing field spec %s if name is the same", incomingGranularitySpec, outgoingGranularitySpec); Preconditions.checkState( incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) && outgoingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()), "Cannot perform time conversion for time format other than EPOCH. TimeFieldSpec: %s", fieldSpec); } }  static void validate(Schema schema, List<TableConfig> tableConfigs); static void validate(Schema schema); }
SchemaUtils { private static void validateTimeFieldSpec(FieldSpec fieldSpec) { TimeFieldSpec timeFieldSpec = (TimeFieldSpec) fieldSpec; TimeGranularitySpec incomingGranularitySpec = timeFieldSpec.getIncomingGranularitySpec(); TimeGranularitySpec outgoingGranularitySpec = timeFieldSpec.getOutgoingGranularitySpec(); if (!incomingGranularitySpec.equals(outgoingGranularitySpec)) { Preconditions.checkState(!incomingGranularitySpec.getName().equals(outgoingGranularitySpec.getName()), "Cannot convert from incoming field spec %s to outgoing field spec %s if name is the same", incomingGranularitySpec, outgoingGranularitySpec); Preconditions.checkState( incomingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()) && outgoingGranularitySpec.getTimeFormat().equals(TimeGranularitySpec.TimeFormat.EPOCH.toString()), "Cannot perform time conversion for time format other than EPOCH. TimeFieldSpec: %s", fieldSpec); } }  static void validate(Schema schema, List<TableConfig> tableConfigs); static void validate(Schema schema); static final String MAP_KEY_COLUMN_SUFFIX; static final String MAP_VALUE_COLUMN_SUFFIX; }