@Test(expected = IllegalArgumentException.class) public void shouldErrorIfNamesUsedNotUnique() { FeatureTableSpec badSpec = DataGenerator.createFeatureTableSpec( "driver", List.of("region"), Map.of("region", STRING), 3600, Map.of()); FeatureTableValidator.validateSpec(badSpec); }
public static void validateSpec(FeatureTableSpec spec) { if (spec.getName().isEmpty()) { throw new IllegalArgumentException("FeatureTable name must be provided"); } if (spec.getLabelsMap().containsKey("")) { throw new IllegalArgumentException("FeatureTable cannot have labels with empty key."); } if (spec.getEntitiesCount() == 0) { throw new IllegalArgumentException("FeatureTable entities list cannot be empty."); } if (spec.getFeaturesCount() == 0) { throw new IllegalArgumentException("FeatureTable features list cannot be empty."); } if (!spec.hasBatchSource()) { throw new IllegalArgumentException("FeatureTable batch source cannot be empty."); } checkValidCharacters(spec.getName(), "FeatureTable"); spec.getFeaturesList().forEach(FeatureTableValidator::validateFeatureSpec); if (!spec.getBatchSource().getBigqueryOptions().getTableRef().isEmpty()) { checkValidBigQueryTableRef( spec.getBatchSource().getBigqueryOptions().getTableRef(), "FeatureTable"); } ArrayList<String> fieldNames = new ArrayList<>(spec.getEntitiesList()); fieldNames.addAll( spec.getFeaturesList().stream().map(FeatureSpecV2::getName).collect(Collectors.toList())); if (!Collections.disjoint(fieldNames, RESERVED_NAMES)) { throw new IllegalArgumentException( String.format( "Reserved names has been used as Feature(s) names. Reserved: %s", RESERVED_NAMES)); } if (hasDuplicates(fieldNames)) { throw new IllegalArgumentException( String.format("Entity and Feature names within a Feature Table should be unique.")); } }
FeatureTableValidator { public static void validateSpec(FeatureTableSpec spec) { if (spec.getName().isEmpty()) { throw new IllegalArgumentException("FeatureTable name must be provided"); } if (spec.getLabelsMap().containsKey("")) { throw new IllegalArgumentException("FeatureTable cannot have labels with empty key."); } if (spec.getEntitiesCount() == 0) { throw new IllegalArgumentException("FeatureTable entities list cannot be empty."); } if (spec.getFeaturesCount() == 0) { throw new IllegalArgumentException("FeatureTable features list cannot be empty."); } if (!spec.hasBatchSource()) { throw new IllegalArgumentException("FeatureTable batch source cannot be empty."); } checkValidCharacters(spec.getName(), "FeatureTable"); spec.getFeaturesList().forEach(FeatureTableValidator::validateFeatureSpec); if (!spec.getBatchSource().getBigqueryOptions().getTableRef().isEmpty()) { checkValidBigQueryTableRef( spec.getBatchSource().getBigqueryOptions().getTableRef(), "FeatureTable"); } ArrayList<String> fieldNames = new ArrayList<>(spec.getEntitiesList()); fieldNames.addAll( spec.getFeaturesList().stream().map(FeatureSpecV2::getName).collect(Collectors.toList())); if (!Collections.disjoint(fieldNames, RESERVED_NAMES)) { throw new IllegalArgumentException( String.format( "Reserved names has been used as Feature(s) names. Reserved: %s", RESERVED_NAMES)); } if (hasDuplicates(fieldNames)) { throw new IllegalArgumentException( String.format("Entity and Feature names within a Feature Table should be unique.")); } } }
FeatureTableValidator { public static void validateSpec(FeatureTableSpec spec) { if (spec.getName().isEmpty()) { throw new IllegalArgumentException("FeatureTable name must be provided"); } if (spec.getLabelsMap().containsKey("")) { throw new IllegalArgumentException("FeatureTable cannot have labels with empty key."); } if (spec.getEntitiesCount() == 0) { throw new IllegalArgumentException("FeatureTable entities list cannot be empty."); } if (spec.getFeaturesCount() == 0) { throw new IllegalArgumentException("FeatureTable features list cannot be empty."); } if (!spec.hasBatchSource()) { throw new IllegalArgumentException("FeatureTable batch source cannot be empty."); } checkValidCharacters(spec.getName(), "FeatureTable"); spec.getFeaturesList().forEach(FeatureTableValidator::validateFeatureSpec); if (!spec.getBatchSource().getBigqueryOptions().getTableRef().isEmpty()) { checkValidBigQueryTableRef( spec.getBatchSource().getBigqueryOptions().getTableRef(), "FeatureTable"); } ArrayList<String> fieldNames = new ArrayList<>(spec.getEntitiesList()); fieldNames.addAll( spec.getFeaturesList().stream().map(FeatureSpecV2::getName).collect(Collectors.toList())); if (!Collections.disjoint(fieldNames, RESERVED_NAMES)) { throw new IllegalArgumentException( String.format( "Reserved names has been used as Feature(s) names. Reserved: %s", RESERVED_NAMES)); } if (hasDuplicates(fieldNames)) { throw new IllegalArgumentException( String.format("Entity and Feature names within a Feature Table should be unique.")); } }  }
FeatureTableValidator { public static void validateSpec(FeatureTableSpec spec) { if (spec.getName().isEmpty()) { throw new IllegalArgumentException("FeatureTable name must be provided"); } if (spec.getLabelsMap().containsKey("")) { throw new IllegalArgumentException("FeatureTable cannot have labels with empty key."); } if (spec.getEntitiesCount() == 0) { throw new IllegalArgumentException("FeatureTable entities list cannot be empty."); } if (spec.getFeaturesCount() == 0) { throw new IllegalArgumentException("FeatureTable features list cannot be empty."); } if (!spec.hasBatchSource()) { throw new IllegalArgumentException("FeatureTable batch source cannot be empty."); } checkValidCharacters(spec.getName(), "FeatureTable"); spec.getFeaturesList().forEach(FeatureTableValidator::validateFeatureSpec); if (!spec.getBatchSource().getBigqueryOptions().getTableRef().isEmpty()) { checkValidBigQueryTableRef( spec.getBatchSource().getBigqueryOptions().getTableRef(), "FeatureTable"); } ArrayList<String> fieldNames = new ArrayList<>(spec.getEntitiesList()); fieldNames.addAll( spec.getFeaturesList().stream().map(FeatureSpecV2::getName).collect(Collectors.toList())); if (!Collections.disjoint(fieldNames, RESERVED_NAMES)) { throw new IllegalArgumentException( String.format( "Reserved names has been used as Feature(s) names. Reserved: %s", RESERVED_NAMES)); } if (hasDuplicates(fieldNames)) { throw new IllegalArgumentException( String.format("Entity and Feature names within a Feature Table should be unique.")); } }  static void validateSpec(FeatureTableSpec spec); }
FeatureTableValidator { public static void validateSpec(FeatureTableSpec spec) { if (spec.getName().isEmpty()) { throw new IllegalArgumentException("FeatureTable name must be provided"); } if (spec.getLabelsMap().containsKey("")) { throw new IllegalArgumentException("FeatureTable cannot have labels with empty key."); } if (spec.getEntitiesCount() == 0) { throw new IllegalArgumentException("FeatureTable entities list cannot be empty."); } if (spec.getFeaturesCount() == 0) { throw new IllegalArgumentException("FeatureTable features list cannot be empty."); } if (!spec.hasBatchSource()) { throw new IllegalArgumentException("FeatureTable batch source cannot be empty."); } checkValidCharacters(spec.getName(), "FeatureTable"); spec.getFeaturesList().forEach(FeatureTableValidator::validateFeatureSpec); if (!spec.getBatchSource().getBigqueryOptions().getTableRef().isEmpty()) { checkValidBigQueryTableRef( spec.getBatchSource().getBigqueryOptions().getTableRef(), "FeatureTable"); } ArrayList<String> fieldNames = new ArrayList<>(spec.getEntitiesList()); fieldNames.addAll( spec.getFeaturesList().stream().map(FeatureSpecV2::getName).collect(Collectors.toList())); if (!Collections.disjoint(fieldNames, RESERVED_NAMES)) { throw new IllegalArgumentException( String.format( "Reserved names has been used as Feature(s) names. Reserved: %s", RESERVED_NAMES)); } if (hasDuplicates(fieldNames)) { throw new IllegalArgumentException( String.format("Entity and Feature names within a Feature Table should be unique.")); } }  static void validateSpec(FeatureTableSpec spec);  }