Closed ssserj closed 6 years ago
FWIW: I just tested this on a bunch of existing cql migration files (~50?) with comment lines and it worked swimmingly, the only problem I encountered was parsing multiple empty lines at the end of a .cql
migration file created an error:
Exception in thread "main" java.lang.IllegalStateException: File had a non-terminated cql line
at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
at uk.sky.cqlmigrate.CqlFileParser$LineProcessor.check(CqlFileParser.java:153)
at uk.sky.cqlmigrate.CqlFileParser$LineProcessor.access$000(CqlFileParser.java:50)
at uk.sky.cqlmigrate.CqlFileParser.getCqlStatementsFrom(CqlFileParser.java:45)
at uk.sky.cqlmigrate.SchemaLoader$Loader.apply(SchemaLoader.java:44)
at uk.sky.cqlmigrate.CqlPaths.lambda$applyInSortedOrder$3(CqlPaths.java:56)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at uk.sky.cqlmigrate.CqlPaths.applyInSortedOrder(CqlPaths.java:56)
at uk.sky.cqlmigrate.SchemaLoader.load(SchemaLoader.java:28)
at uk.sky.cqlmigrate.CqlMigratorImpl.migrate(CqlMigratorImpl.java:95)
at uk.sky.cqlmigrate.CqlMigratorImpl.migrate(CqlMigratorImpl.java:67)
at uk.sky.cqlmigrate.CqlMigratorImpl.main(CqlMigratorImpl.java:58)
(this was an easy enough fix, just figured I'd mention as the only thing that we went wrong). It'd be great if this PR merged, I think having support for commenting in CQL migrations would be a nice feature 😄
Sorry, I also forgot to ask if you could add something in the readme file about the comment syntax? Thanks!
CqlFileParser reimplemented (#56). We should ignore code comments, normalize queries and preserve newline in valueExpressions.