Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
}
}
}