Skip to content

isthmus: CREATE OR REPLACE VIEW converts to DDL_OP_CREATE, dropping the replace request #1359

Description

@nielspardon

CREATE OR REPLACE VIEW converts to the same plan as plain CREATE VIEW, so the replace request is lost. DdlSqlToRelConverter.handleCreateView never reads SqlCreateView.getReplace(), and SubstraitRelVisitor.handleCreateView hard-codes DDL_OP_CREATE:

protected RelRoot handleCreateView(final SqlCreateView sqlCreateView) {
final RelNode input = converter.convertQuery(sqlCreateView.query, true, true).rel;
final RelDataType schema = declaredSchema(sqlCreateView.columnList, input);
return RelRoot.of(
schema == null
? new CreateView(sqlCreateView.name.names, input)
: new CreateView(sqlCreateView.name.names, schema, input),
sqlCreateView.getKind());
}

CREATE VIEW v1 AS SELECT v FROM src             -> ddl.op = DDL_OP_CREATE
CREATE OR REPLACE VIEW v1 AS SELECT v FROM src  -> ddl.op = DDL_OP_CREATE

Measured on main at d05cd6b. The spec defines DDL_OP_CREATE_OR_REPLACE for this. The reverse direction, SubstraitRelNodeConverter.visit(NamedDdl), accepts only DDL_OP_CREATE, so it needs to accept the new op too, and CreateView needs to carry it the way CreateTable now carries its create mode (#1266).

Activity

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

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