@@ -54,6 +54,8 @@ public class SpecValidator {
5454 private FeatureInfoRepository featureInfoRepository ;
5555 private static final String FILE_ERROR_STORE_TYPE = "file.json" ;
5656
57+ private static final String NO_STORE = "" ;
58+
5759 private static String [] SUPPORTED_WAREHOUSE_STORES =
5860 new String [] {
5961 BigQueryStorageManager .TYPE , FILE_ERROR_STORE_TYPE ,
@@ -110,8 +112,8 @@ public void validateFeatureSpec(FeatureSpec spec) throws IllegalArgumentExceptio
110112 Strings .lenientFormat ("Entity with name %s does not exist" , spec .getEntity ()));
111113
112114 // TODO: clean up store validation for features
113- String servingStoreId = "" ;
114- String warehouseStoreId = "" ;
115+ String servingStoreId = NO_STORE ;
116+ String warehouseStoreId = NO_STORE ;
115117 if (spec .hasDataStores ()) {
116118 servingStoreId =
117119 spec .getDataStores ().hasServing () ? spec .getDataStores ().getServing ().getId () : "" ;
@@ -126,9 +128,9 @@ public void validateFeatureSpec(FeatureSpec spec) throws IllegalArgumentExceptio
126128 }
127129 FeatureGroupInfo group = (FeatureGroupInfo ) groupOptional .get ();
128130 servingStoreId =
129- servingStoreId .equals ("" ) ? group .getServingStore ().getId () : servingStoreId ;
131+ servingStoreId .equals (NO_STORE ) ? group .getServingStore ().getId () : servingStoreId ;
130132 warehouseStoreId =
131- warehouseStoreId .equals ("" ) ? group .getWarehouseStore ().getId () : warehouseStoreId ;
133+ warehouseStoreId .equals (NO_STORE ) ? group .getWarehouseStore ().getId () : warehouseStoreId ;
132134 }
133135 Optional <StorageInfo > servingStore = storageInfoRepository .findById (servingStoreId );
134136 Optional <StorageInfo > warehouseStore = storageInfoRepository .findById (warehouseStoreId );
@@ -138,13 +140,17 @@ public void validateFeatureSpec(FeatureSpec spec) throws IllegalArgumentExceptio
138140 checkArgument (
139141 Arrays .asList (SUPPORTED_SERVING_STORES ).contains (servingStore .get ().getType ()),
140142 Strings .lenientFormat ("Unsupported serving store type" , servingStore .get ().getType ()));
141- checkArgument (
142- warehouseStore .isPresent (),
143- Strings .lenientFormat ("Warehouse store with id %s does not exist" , warehouseStoreId ));
144- checkArgument (
145- Arrays .asList (SUPPORTED_WAREHOUSE_STORES ).contains (warehouseStore .get ().getType ()),
146- Strings .lenientFormat (
147- "Unsupported warehouse store type" , warehouseStore .get ().getType ()));
143+
144+ if (!warehouseStoreId .equals (NO_STORE )) {
145+ checkArgument (
146+ warehouseStore .isPresent (),
147+ Strings .lenientFormat ("Warehouse store with id %s does not exist" , warehouseStoreId ));
148+
149+ checkArgument (
150+ Arrays .asList (SUPPORTED_WAREHOUSE_STORES ).contains (warehouseStore .get ().getType ()),
151+ Strings .lenientFormat (
152+ "Unsupported warehouse store type" , warehouseStore .get ().getType ()));
153+ }
148154
149155 } catch (NullPointerException | IllegalArgumentException e ) {
150156 throw new IllegalArgumentException (
0 commit comments