Skip to content

refactor(output-mapping): create non-typed tables through the table-definition endpoint - #551

Merged
zajca merged 3 commits into
mainfrom
zajca/om-untyped-create-via-table-definition
Jul 29, 2026
Merged

refactor(output-mapping): create non-typed tables through the table-definition endpoint#551
zajca merged 3 commits into
mainfrom
zajca/om-untyped-create-via-table-definition

Conversation

@zajca

@zajca zajca commented Jul 27, 2026

Copy link
Copy Markdown
Member

Preparation for AJDA-2946 (#550), useful on its own.

Why

Output mapping has two ways of creating a table. Typed tables and tables declared by schema go through createTableDefinition. A table declared by manifest columns without data types went through createTableAsync, which requires a header CSV to be written to a temp file and uploaded to file storage before the table can be created.

The definition endpoint can create that table too: Storage reports a table as typed only when at least one column carries definition.type or basetype (BaseCreateTableDefinitionRequest::isTypedTable()), so a payload with plain column names produces a non-typed table. Verified against real Storage — same isTyped=false, same columns, same primary key, data loads normally.

So this switches the untyped path to createTableDefinition, which:

Changes

  • new TableDefinitionFromColumns — builds {name, primaryKeysNames, columns: [{name}]} and nothing else, so no column can accidentally acquire a type
  • LoadTableTaskCreator uses it for the !didTableExistBefore() && hasColumns() branch
  • TableCreator::createTable() removed — this change made it unused, and with it the header-CSV plumbing (Temp, CsvFile)

Observable differences

distributionKey is no longer set on the created table. Measured side by side, this is the only field that differs; everything else (isTyped, primaryKey, columns, column definitions, metadata rows, import) is identical.

That is acceptable because Storage documents the field as "Distribution key columns (for Synapse)", Synapse is no longer a Storage backend, and on Snowflake it is inert metadata echoed back in the table detail. Note the typed and schema paths already do not set it — so today a typed table created from a config with distribution_key gets no distribution key while an untyped one does. This makes the two consistent.

An invalid column name is reported differently. createTableAsync said '<name>' is more than 64 characters long; the definition endpoint says Invalid column name: "<name>". The new message does not spell out the limit. testLongColumnName was updated accordingly.

Testing

  • phpcs + phpstan (level max) clean.
  • TableCreatorTest — the two tests covering the old createTable() were converted to the new path rather than deleted, so non-typed creation with a primary key and its error handling stay covered against real Storage.
  • New unit test for TableDefinitionFromColumns, including that a sparse column list (RestrictedColumnsHelper filters with array_filter and leaves gaps) still serialises as a JSON array.
  • main-writer-tests-1 run against real Storage: the only failure caused by this change was testLongColumnName (message text, updated). The four Can not resolve branchId dev-branch errors are pre-existing — verified by re-running one of them with these changes stashed, where it fails identically.

@zajca
zajca marked this pull request as ready for review July 28, 2026 08:51

@keboola-pr-reviewer-bot keboola-pr-reviewer-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: needs_human (risk 3/5) · profile ajda

Needs human: removes a public method and changes observable table-creation behavior in load-bearing platform-libraries, with no feature-flag gate.

Concerns:

  • libs/output-mapping/src/Storage/TableCreator.php: Public method createTable() removed — potential BC break for library consumers
  • libs/output-mapping/src/LoadTableTaskCreator.php: distributionKey no longer set on created tables; behavior change with no feature flag
  • libs/output-mapping/tests/Writer/StorageApiLocalTableWriterTest.php: User-facing invalid-column-name error message changed

@zajca
zajca requested review from odinuv and ondrajodas July 28, 2026 08:52

@odinuv odinuv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

může bejt

podle mě ty komentáře, který popisují změnu "// takže vznikne netypovaná tabulka stejně jako dřív, ale bez uploadu hlavičkového CSV souboru" všeobecně nepatří do kódu, ale do PR

$this->fail('Must throw exception');
} catch (InvalidOutputException $e) {
// the table is created through the table-definition endpoint, which reports an invalid column
// name without spelling out the length limit

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

to je škoda :)

zajca added 3 commits July 29, 2026 10:34
…efinition endpoint

A table declared by manifest `columns` without data types was created with
createTableAsync, which needs a header CSV uploaded to file storage first. The
same table can be created through the table-definition endpoint by sending the
columns without any type - Storage reports a table as typed only when at least
one column carries `definition.type` or `basetype` - so the create now goes
through createTableDefinition and the file upload disappears.

This also aligns the untyped path with the typed and schema paths, which already
create tables through the same endpoint.

Two observable differences:

- distributionKey is no longer set on the created table. Storage documents it as
  a Synapse-only field, Synapse is gone, and the typed paths do not set it either,
  so this makes output mapping consistent rather than losing behaviour that works.
- an invalid column name is now reported by Storage as `Invalid column name: "..."`
  instead of naming the 64 character limit.
…on-typed create

The non-typed branch now reads primaryKey/columns twice and the definition
endpoint reports an invalid column name instead of the length limit.
@zajca
zajca force-pushed the zajca/om-untyped-create-via-table-definition branch from 311291d to 707acc6 Compare July 29, 2026 08:34
@zajca
zajca merged commit 4922066 into main Jul 29, 2026
33 checks passed
@zajca
zajca deleted the zajca/om-untyped-create-via-table-definition branch July 29, 2026 09:12
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