Skip to content

isthmus: visit(NamedWrite) ignores output_mode, so a write declaring MODIFIED_RECORDS converts to a ROWCOUNT TableModify #1213

Description

@nielspardon

visit(NamedWrite) never reads getOutputMode() on the INSERT and DELETE paths -- only handleCreateTableAs checks it, for CTAS -- and returns a LogicalTableModify whose row type is a single ROWCOUNT column:

return LogicalTableModify.create(
targetTable,
requireCatalogReader(relOptSchema, write.getNames()),
input,
operation,
null,
null,
false);

The plan says otherwise. AbstractWriteRel.deriveRecordType() returns the input's record type, and the spec documents OUTPUT_MODE_MODIFIED_RECORDS as returning the records the operator inserted, deleted or updated, further manipulable upstream. So a write declaring MODIFIED_RECORDS converts to a relation that reports one column where the plan declares the input's, and a parent reading it resolves its references against columns that are not there.

isthmus produces those plans itself -- the export direction stamps the mode on every INSERT and DELETE:

.outputMode(AbstractWriteRel.OutputMode.MODIFIED_RECORDS)

#1189 refuses an emit mapping on a write because the mode is dropped, and its message says so, but the drop itself is still silent. Either refuse MODIFIED_RECORDS the way the mapping is now refused, or model it.

Found while reviewing #1189.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions