diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala index 7fcde62..85631e1 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJelly.scala @@ -8,6 +8,7 @@ import eu.neverblink.jelly.cli.command.rdf.util.RdfFormat.* import eu.neverblink.jelly.cli.util.jena.riot.JellyStreamWriterGraphs import eu.neverblink.jelly.convert.jena.JenaConverterFactory import eu.neverblink.jelly.convert.jena.riot.{JellyFormatVariant, JellyLanguage, JellyStreamWriter} +import eu.neverblink.jelly.core.{JellyOptions, RdfProtoDeserializationError} import eu.neverblink.jelly.core.proto.google.v1 as google import eu.neverblink.jelly.core.proto.v1.{LogicalStreamType, PhysicalStreamType, RdfStreamOptions} import org.apache.jena.riot.lang.LabelToNode @@ -82,6 +83,7 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable options.inputFormat, remainingArgs.remaining.headOption, ) + if !isQuietMode then checkAndWarnTypeCombination() override def matchFormatToAction( format: RdfFormat.Readable, @@ -191,6 +193,26 @@ object RdfToJelly extends RdfSerDesCommand[RdfToJellyOptions, RdfFormat.Readable } } + private def checkAndWarnTypeCombination(): Unit = { + + val rdfStreamOptions = getOptions.jellySerializationOptions.asRdfStreamOptions + val physicalType = rdfStreamOptions.getPhysicalType + val logicalType = rdfStreamOptions.getLogicalType + + try { + // This check will find physical/logical clashes, since all other fields are checked with <=, + // so they pass when compared against themselves + JellyOptions.checkCompatibility(rdfStreamOptions, rdfStreamOptions) + } catch { + case _: RdfProtoDeserializationError => + printLine( + s"WARNING: Selected combination of logical/physical stream types ($logicalType/$physicalType) is unsupported. " + + "Use --quiet to silence this warning.", + true, + ) + } + } + /** Check if the logical type is defined and grouped. * @param jellyOpt * the Jelly options diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala index c6cf447..6a87d9d 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/rdf/RdfToJellySpec.scala @@ -685,4 +685,46 @@ class RdfToJellySpec extends AnyWordSpec with TestFixtureHelper with Matchers: e.code should be(1) } } + + "emit a warning" when { + "requesting an unsupported logical / physical combination" in withFullJenaFile { f => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + "--opt.logical-type=SUBJECT_GRAPHS", + "--opt.physical-type=QUADS", + f, + ), + ) + err should ( + include("WARNING") and + include("unsupported") and + include("SUBJECT_GRAPHS/QUADS") + ) + } + } + + "not emit a warning" when { + "requesting an unsupported logical / physical combination with --quiet flag" in withFullJenaFile { + f => + val (out, err) = + RdfToJelly.runTestCommand( + List( + "rdf", + "to-jelly", + "--quiet", + "--opt.logical-type=SUBJECT_GRAPHS", + "--opt.physical-type=QUADS", + f, + ), + ) + err should not( + include("WARNING") and + include("unsupported") and + include("SUBJECT_GRAPHS/QUADS"), + ) + } + } }