@@ -196,12 +196,13 @@ protected boolean doCheckExistingTable(NosqlEntityInformation<?, ?> entityInform
196196 final String primaryField = "primaryKey" ;
197197 final String ttlField = "ttl" ;
198198 final String identityField = "identity" ;
199- final String schemaVersionField = "json_version" ;
200- final int supportedSchemaVersion = 1 ;
201199
202200 List <String > errors = new ArrayList <>();
201+
202+ TableResult tableResult = null ;
203+ String jsonSchema = null ;
203204 try {
204- TableResult tableResult = doGetTable (entityInformation );
205+ tableResult = doGetTable (entityInformation );
205206
206207 // table does not exist return false
207208 if (tableResult == null ) {
@@ -210,27 +211,11 @@ protected boolean doCheckExistingTable(NosqlEntityInformation<?, ?> entityInform
210211
211212 /* If table already exist in the database compare and throw error if
212213 mismatch*/
213- MapValue tableSchema = JsonUtils . createValueFromJson (
214- tableResult . getSchema () ,
214+ jsonSchema = tableResult . getSchema ();
215+ MapValue tableSchema = JsonUtils . createValueFromJson ( jsonSchema ,
215216 new JsonOptions ().setMaintainInsertionOrder (true )).
216217 asMap ();
217218
218- int currentSchemaVersion = tableSchema .get (schemaVersionField ).
219- getInt ();
220-
221- // If JSON schema version mismatch throw error
222- if (currentSchemaVersion != supportedSchemaVersion ) {
223- String msg = String .format ("Could not validate schema of the " +
224- "table %s in the database and entity %s : " +
225- "json schema version mismatch. " +
226- "Expected version is %s but version is %s" ,
227- entityInformation .getTableName (),
228- entityInformation .getJavaType ().getName (),
229- currentSchemaVersion ,
230- supportedSchemaVersion );
231- throw new IllegalStateException (msg );
232- }
233-
234219 ArrayValue tableColumns = tableSchema .get (colField ).asArray ();
235220 ArrayValue tableShardKeys =
236221 tableSchema .get (shardField ).asArray ();
@@ -275,7 +260,7 @@ protected boolean doCheckExistingTable(NosqlEntityInformation<?, ?> entityInform
275260 Map <String , String > entityOthersMap = new LinkedHashMap <>();
276261 entityOthersMap .put (JSON_COLUMN .toLowerCase (), "json" );
277262
278- // convert maps to String
263+ // convert maps to String. String format is {k1 v1, k2 v2 ...}
279264 String tableShards = "{" + tableShardMap .entrySet ().stream ()
280265 .map (e -> e .getKey () + " " + e .getValue ()).
281266 collect (Collectors .joining ("," )) + "}" ;
@@ -347,10 +332,16 @@ protected boolean doCheckExistingTable(NosqlEntityInformation<?, ?> entityInform
347332 }
348333 } catch (NullPointerException | ClassCastException ex ) {
349334 // something is wrong in parsing json schema
350- String msg = String .format ("Table %s json schema is not " +
351- "compatible with schema version %s" ,
335+ String msg = String .format ("Could not validate schema of the " +
336+ "table %s in the database against entity %s : " +
337+ "%s" ,
352338 entityInformation .getTableName (),
353- supportedSchemaVersion );
339+ entityInformation .getJavaType ().getName (),
340+ ex .getMessage ());
341+
342+ if (LOG .isDebugEnabled ()) {
343+ LOG .debug ("JSON Schema of the table is " + jsonSchema );
344+ }
354345 throw new IllegalStateException (msg , ex );
355346 }
356347
0 commit comments