Skip to content

PDPS-2211 Add --column-name-strategy for structured-data imports - #678

Open
stevebio wants to merge 5 commits into
feature/source-uri-option-2from
feature/column-name-sanitization
Open

stevebio wants to merge 5 commits into
feature/source-uri-option-2from
feature/column-name-sanitization

Conversation

@stevebio

@stevebio stevebio commented Sep 29, 2026 •

Copy link
Copy Markdown

Summary

  • Add --column-name-strategy to structured-data imports: none (default) preserves existing behavior, while simple sanitizes column names.
  • Apply sanitization to Avro, delimited, JDBC, ORC, and Parquet imports. The simple strategy folds Western European letters, replaces unsupported character runs with underscores, and preserves original underscores.
  • Implement sanitization via a ColumnNameSanitizer interface (SimpleColumnNameSanitizer), decoupled from the Spark Dataset API.
  • Report an error if sanitization produces an empty name or duplicate names.
  • Document the option and its interaction with filtering, grouping, and aggregation.

Testing

  • Unit tests for SimpleColumnNameSanitizer covering folding, underscores, collisions, and empty names.
  • Tests for strategy parsing, plus one integration test each for CLI and API delimited-file imports.

stevebio and others added 2 commits September 28, 2026 16:22
Adds a --column-name-strategy option (and matching Java API method)
for import-avro-files, import-delimited-files, import-jdbc,
import-orc-files, and import-parquet-files, applied after --where,
--drop, and --group-by/--aggregate/--aggregate-order-by so those
options can still reference original column names.

- none (default): column names are left unchanged, preserving
  existing behavior.
- simple: folds Western European Latin letters to their closest ASCII
  equivalent (e.g. 'é' -> 'e', 'ö' -> 'o', 'ß' -> 'ss', via Unicode NFD
  normalization plus an explicit mapping for letters that don't
  decompose, such as 'æ' -> 'ae'), then replaces each remaining run of
  non-ASCII-alphanumeric characters (including existing underscores)
  with a single underscore and trims leading/trailing underscores.
  Sanitization is applied via a single positional rename so a column's
  sanitized name colliding with another column's original name doesn't
  produce a false intermediate collision. Raises a FluxException if
  sanitization would produce an empty name or a collision between two
  different columns.

Also documents the feature in docs/import/structured-data, and bumps
the test task's max heap size to prevent OOM in Spark tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Underscores in the original column name may be meaningful, so the simple
strategy no longer collapses or trims them. Only leading/trailing runs of
other unsupported characters are removed, and interior runs are replaced
with a single underscore.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@rjrudin rjrudin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few comments about moving some furniture around.

Addresses PR #678 review feedback:
- Move sanitizing logic into a ColumnNameSanitizer interface with a
  SimpleColumnNameSanitizer implementation, decoupled from the Dataset API.
- Replace Spark-based sanitization tests with unit tests on the sanitizer,
  keeping one integration test in ImportDelimitedFilesTest.
- Drop option-ordering detail from the --column-name-strategy description.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 21:00
@stevebio stevebio changed the title Feature/column name sanitization Add --column-name-strategy for structured-data imports Sep 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The public API addition affects existing implementations, and the sanitizer can miss duplicate names or silently remove unsupported marks.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity · 1 Low severity

Open (4)
What changed in this PR

This PR adds optional column-name sanitization to structured-data imports before documents are constructed.

Changes:

  • Adds the none and simple strategies to five import commands and their APIs.
  • Adds sanitizer, option-parsing, and delimited-import tests.
  • Documents the option and sets a 4 GB maximum heap for tests.
File Description
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​importdata/​SimpleColumnNameSanitizerTest.java Tests name conversion and errors.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportDelimitedFilesTest.java Tests the CLI import option.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​impl/​importdata/​ColumnNameStrategyOptionsTest.java Tests defaults and option parsing.
flux-cli/​src/​test/​java/​com/​marklogic/​flux/​api/​DelimitedFilesImporterTest.java Tests API-based sanitization.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​StructuredDataParams.java Applies sanitization after transformations.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​SimpleColumnNameSanitizer.java Implements the simple strategy.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportParquetFilesCommand.java Exposes the Parquet API option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportOrcFilesCommand.java Exposes the ORC API option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportJdbcCommand.java Exposes the JDBC API option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportDelimitedFilesCommand.java Exposes the delimited-file API option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ImportAvroFilesCommand.java Exposes the Avro API option.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​impl/​importdata/​ColumnNameSanitizer.java Defines the sanitizer interface.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​api/​StructuredDataImporter.java Adds the importer API method.
flux-cli/​src/​main/​java/​com/​marklogic/​flux/​api/​ColumnNameStrategy.java Defines the available strategies.
docs/​import/​structured-data/​sanitizing-column-names.md Documents usage and limitations.
docs/​import/​structured-data/​overview.md Links to the new guide.
build.gradle Sets the test maximum heap.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread flux-cli/src/main/java/com/marklogic/flux/api/StructuredDataImporter.java Outdated
Comment thread docs/import/structured-data/sanitizing-column-names.md
@stevebio
stevebio requested a review from rjrudin September 29, 2026 21:06
stevebio and others added 2 commits September 29, 2026 14:18
Keeps existing external implementations of the public interface source- and binary-compatible.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@stevebio stevebio changed the title Add --column-name-strategy for structured-data imports PDPS-2211 Add --column-name-strategy for structured-data imports Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants