Releases: marklogic/marklogic-spark-connector
3.0.0
This major release is built against Apache Spark 4.1.0 instead of Spark 3, and thus requires Java 17. Please see below for a complete list of breaking changes, enhancements, and bug fixes.
Breaking Changes
- When splitting text and creating chunks, the connector now defaults to creating one sidecar document per chunk as opposed to defaulting to adding all chunks to the source document.
- Vector embeddings in XML documents now default to a QName of
vectorwith a namespace ofhttp://marklogic.com/vector, matching upcoming default index exclusions in the MarkLogic server. - Vector embeddings in JSON documents now default to a name of
_vector, also matching upcoming default index exclusions in the MarkLogic server. - The deprecated
spark.marklogic.write.fileRows.documentTypeoption has been removed. This option was intended to be used with Spark'sbinaryFiledata source, but binary files should instead be read with this connector's own support for reading files. - The
com.marklogic.client,okhttp3,okio, andcom.burgstaller.okhttppackages are no longer shaded in the connector jar. These had to be shaded when the connector depended on Spark 3 as Spark 3 included its own older version of OkHttp.
Enhancements
- When a URI template has an expression that cannot be resolved for a given document, the new
spark.marklogic.write.uriTemplate.warnOnMissingFieldoption can be set totrueto log a warning instead of failing. The expression will have its value replaced withUNRESOLVED-prepended to a random UUID. - When reading files, the connector now defaults a number of partitions equal to the value of
spark.default.parallelism, helping avoid performance issues due to large numbers of very small partitions. - When classifying text via a Semaphore instance in Progress Data Cloud (PDC), the PDC token will be renewed if it expires during the course of a connector job.
- When exporting documents to zip file, a warning will be logged once a zip file contains 500,000 entries. Writing multiple large zip files at once can lead to heap space exhaustion in the JVM; users can avoid this by increasing the number of partitions.
- Added
spark.marklogic.read.partitions.vars.as a prefix for defining variables to send to the custom code for reading partitions when reading items via custom code.
Bug Fixes
- Fixed a bug with writing triples where
datatypeis only set iflangdoes not exist. - Fixed a bug where, when reading files, a partition could have zero files. Files are now evenly distributed across partitions.
- Fixed a bug with exporting documents to zip files on Windows.
2.7.0
This minor release addresses the following items:
- Can now provide a secondary query when reading documents from MarkLogic. This is supported via the following new options:
spark.marklogic.read.secondaryUris.invokespark.marklogic.read.secondaryUris.javascriptspark.marklogic.read.secondaryUris.javascriptFilespark.marklogic.read.secondaryUris.xqueryspark.marklogic.read.secondaryUris.xqueryFilespark.marklogic.read.secondaryUris.vars.
- Can now provide a prompt when generating an embedding via the new
spark.marklogic.write.embedder.promptoption. - Can now encode vectors in documents when generating embeddings via the new
spark.marklogic.write.embedder.base64encodeoption. - Fixed a bug where classifying text and generating embeddings did not work when data was read from a structured data source such as JDBC or a delimited text file.
- Fixed a bug where a document with a URI containing multiple colons could not be read from MarkLogic and written to a file.
- Fixed a bug where URIs were incorrectly modified when documents were written as entries in a zip file. URIs are now used as the zip entry name.
2.6.0
This release addresses the following items:
- Can now extract text from binary documents via Apache Tika .
- Can now classify text via Progress Semaphore.
- Can now specify document properties and metadata values when writing documents to MarkLogic.
2.5.1
This patch release addresses the following items:
- Depends on the MarkLogic Java Client 7.1.0 release, which includes an important bug fix that affects how the connector reads data via custom code.
- Added debug-level logging for reading and writing data via custom code.
- Fixed an issue with logging progress when reading rows via an Optic query.
2.5.0
This release addresses the following items:
- Can now split text in documents when writing them to MarkLogic. Chunks of text can be added to the source document itself or written to separate sidecar documents.
- Can now add embeddings to chunks in documents before writing them to MarkLogic. You can reuse the Flux embedding model integrations available from the Flux releases site by adding one or more of these JAR files to your Spark classpath.
- When reading rows via an Optic query, the Optic query no longer requires the use of
op.fromView. However, when not usingop.fromView, the Optic query will be executed in a single call to MarkLogic. - When writing files to a directory, the given path will be created automatically if it does not exist, matching the behavior of Spark file-based data sources.
Please see the writing guide for more information on the splitter and embedder features.
2.4.2
This patch release addresses the following two issues:
spark.marklogic.read.snapshotwas added to allow a user to configure a non-consistent snapshot when reading documents by setting the option tofalse. This avoids bugs where a consistent snapshot is not feasible and the downsides of reading at multiple times are not a concern.- Issues with importing JSON Lines files via Flux - such as keys being reordered and added - can be avoided by setting the existing
spark.marklogic.read.files.typeoption to a value ofjson_lines. The connector will read each line as a separate JSON document and will not perform any modifications on any line, thereby avoiding the issue in Flux of JSON documents being unexpectedly altered.
2.4.1
This patch release addresses a single issue:
- The
org.slf4j:slf4j-apitransitive dependency is forced to be version 2.0.13, ensuring that no occurrences of the 1.x version of that dependency are included in the connector jar. This resolves a logging issue in the Flux application.
2.4.0
This minor release addresses the following items:
- Can now stream regular files, ZIP files, gzip files, and archive files by setting the new
spark.marklogic.streamFilesoption to a value oftrue. Using this option in the reader phase results in the reading of files being deferred until the writer phase. Using this option in the writer phase results in each file being streamed to MarkLogic in a separate request to MarkLogic, thus avoiding ever reading the contents of the file or zip entry into memory. - Can now stream documents from MarkLogic to regular files, ZIP files, gzip files, and archive files by setting the same option above -
spark.marklogic.streamFiles- to a value of `true. Using this option in the reader phase results in the reading of documents being deferred until the writer phase. Using this option in the writer phase results in each document being streamed from MarkLogic to a file or zip entry, thus avoiding ever reading the contents of the document into memory. - Files with spaces in the path are now handled correctly when reading files into MarkLogic. However, when streaming files into MarkLogic, the spaces in the path will be encoded due to a pending server fix.
- Archive files - zip files containing content and metadata - now contain the metadata entry followed by the content entry for each document. This supports streaming archive files. Archive files generated by version 2.3.x of the connector - with the content entry followed by the metadata entry - can still be read, though they cannot be streamed.
- Now compiled and tested against Spark 3.5.3.
2.3.1
This patch release addresses the following issues:
- Can now read document URIs that include non-US-ASCII characters. This was fixed via an upgrade of the Java Client to its 7.0.0 release, whose breaking changes do not have impact on this connector release.
- Registered
collatedStringas a known TDE type, thereby avoiding warnings when reading rows from a TDE that uses that type. - Significantly improved performance when reading aggregate XML files and extracting a URI value from an element.
- Fixed bug where a message of "Wrote failed documents to archive file at" was logged when no documents failed.
2.3.0
This minor release provides significant new functionality in support of the 1.0.0 release of the new MarkLogic Flux data movement tool. Much of this functionality is documented in the Flux documentation. We will soon have complete documentation of all the new options in this repository's documentation as well.
In the meantime, the new options in this release are listed below.
Read Options
spark.marklogic.read.javascriptFileandspark.marklogic.read.xqueryFileallow for custom code to be read from a file path.spark.marklogic.read.partitions.javascriptFileandspark.marklogic.read.partitions.xqueryFileallow for custom code to be read from a file path.- Can now read document rows by specifying a list of newline-delimited URIs via the
spark.marklogic.read.documents.urisoption. - Can now read rows containing semantic triples in MarkLogic via
spark.marklogic.read.triples.graphs,spark.marklogic.read.triples.collections,spark.marklogic.read.triples.query,spark.marklogic.read.triples.stringQuery,spark.marklogic.read.triples.uris,spark.marklogic.read.triples.directory,spark.marklogic.read.triples.options,spark.marklogic.read.triples.filtered, andspark.marklogic.read.triples.baseIri. - Can now read Flux and MLCP archives by setting
spark.marklogic.read.files.typetoarchiveormlcp_archive. - Can control which categories of metadata are read from Flux archives via
spark.marklogic.read.archives.categories. - Can now specify the encoding of a file to read via
spark.marklogic.read.files.encoding. - Can now see progress logged of reading data from MarkLogic via
spark.marklogic.read.logProgress. - Can specify whether to fail on a file read error via
spark.marklogic.read.files.abortOnFailure.
Write Options
spark.marklogic.write.threadCounthas been altered to reflect the common user understanding of "number of threads used to connect to MarkLogic". If you need to specify a thread count per partition, usespark.marklogic.write.threadCountPerPartition.- Can now see progress logged of data written to MarkLogic via
spark.marklogic.write.logProgress. spark.marklogic.write.javascriptFileandspark.marklogic.write.xqueryFileallow for custom code to be read from a file path.- Setting
spark.marklogic.write.archivePathForFailedDocumentsto a file path will result in any failed documents being added to an archive zip file at that file path. spark.marklogic.write.jsonRootNameallows for a root field to be added to a JSON document constructed from an arbitrary row.spark.marklogic.write.xmlRootNameandspark.marklogic.write.xmlNamespaceallow for an XML document to be constructed from an arbitrary row.- Options starting with
spark.marklogic.write.json.will be used to configure how the connector serializes a Spark row into a JSON object. - Can use
spark.marklogic.write.graphandspark.marklogic.write.graphOverrideto specify the graph when writing RDF triples to MarkLogic. - Deprecated
spark.marklogic.write.fileRows.documentTypein favor of usingspark.marklogic.write.documentTypeto force a document type on documents written to MarkLogic with an extension unrecognized by MarkLogic. - Can use
spark.marklogic.write.files.prettyPrintto pretty-print JSON and XML files written by the connector. - Can use
spark.marklogic.write.files.encodingto write files in a different encoding. - Can use
spark.marklogic.write.files.rdf.formatto specify an RDF type when writing triples to RDF files. - Can use
spark.marklogic.write.files.rdf.graphto specify a graph when writing RDF files.