Skip to content

Two more re-render defects that are unparseable or lossy, and the DDL statements with no copy() at all #7800

Closed

Description

@ruispereira

Summary (three small items in the same family)

  1. CreateMaterializedViewStatement.toString() emits a PERIODIC keyword the grammar does not
    have, so the rendered statement is a syntax error. The sibling
    AlterMaterializedViewStatement.toString() handles the same refreshMode correctly.
  2. Url.toString() prints the raw string, so a URL that arrived as a quoted STRING_LITERAL
    without a recognised scheme loses its quotes and the render no longer parses.
  3. Twelve DDL statements have no copy() override and throw
    UnsupportedOperationException("IMPLEMENT copy() ON <X>"); DropIndexStatement.copy() exists but
    silently drops ifExists, and TraverseStatement.copy() drops skip,
    UpdateStatement.copy() drops returnCount.

Where (HEAD 417314c)

engine/src/main/java/com/arcadedb/query/sql/parser/CreateMaterializedViewStatement.java:89

    if (refreshMode != null) {
      sb.append(" REFRESH ").append(refreshMode);          // refreshMode is "PERIODIC" (SQLASTBuilder:6675)
      if ("PERIODIC".equalsIgnoreCase(refreshMode) && refreshInterval > 0)
        sb.append(" EVERY ").append(refreshInterval).append(' ').append(refreshUnit);
    }

versus engine/src/main/java/com/arcadedb/query/sql/parser/AlterMaterializedViewStatement.java:82

    sb.append(name).append(" REFRESH ");
    if ("PERIODIC".equalsIgnoreCase(refreshMode) && refreshInterval > 0)
      sb.append("EVERY ").append(refreshInterval).append(' ').append(refreshUnit);
    else
      sb.append(refreshMode);

(grammar: materializedViewRefreshClause : REFRESH MANUAL | REFRESH INCREMENTAL | REFRESH EVERY INTEGER_LITERAL materializedViewTimeUnit - there is no PERIODIC token.)

engine/src/main/java/com/arcadedb/query/sql/parser/Url.java:37

  public void toString(final Map<String, Object> params, final StringBuilder builder) {
    builder.append(urlString);
  }

engine/src/main/java/com/arcadedb/query/sql/parser/DropIndexStatement.java (copy()) - no result.ifExists = ifExists;

Repro

$ java -cp ... RT corpus_raw.txt
REPARSE-FAIL | CREATE MATERIALIZED VIEW AlterPMView AS SELECT name FROM Account REFRESH EVERY 1 SECOND
   render: CREATE MATERIALIZED VIEW AlterPMView AS SELECT name FROM Account REFRESH PERIODIC EVERY 1 SECOND
   err: ... mismatched input 'PERIODIC' expecting {<EOF>, ';'}

REPARSE-FAIL | BACKUP DATABASE 'mybackup.zip'
   render: BACKUP DATABASE mybackup.zip
   err: ... mismatched input 'mybackup' expecting {<EOF>, ';'}

COPY-DIFF | DROP INDEX Foo IF EXISTS
   orig: DROP INDEX Foo IF EXISTS
   copy: DROP INDEX Foo

$ grep -A3 '^COPY-FAIL' out_raw.txt | grep '^COPY-FAIL' | sed 's/.*-> //' | sort | uniq -c | sort -rn
  28 UnsupportedOperationException: IMPLEMENT copy() ON CheckDatabaseStatement
  15 ... DropMaterializedViewStatement
  14 ... CreateMaterializedViewStatement
  14 ... CreateGraphAnalyticalViewStatement
  12 ... DropGraphAnalyticalViewStatement
   6 ... AlterMaterializedViewStatement
   5 ... AlterGraphAnalyticalViewStatement
   2 ... DropContinuousAggregateStatement
   1 ... RefreshMaterializedViewStatement
   1 ... RefreshContinuousAggregateStatement
   1 ... RebuildGraphAnalyticalViewStatement
   1 ... AlignDatabaseStatement

Suggested fix

  1. Use the AlterMaterializedViewStatement shape (emit REFRESH EVERY n UNIT for PERIODIC).
  2. Quote the URL in Url.toString() when it is not one of the scheme-prefixed forms the lexer has a
    token for (FILE_URL/HTTP_URL/HTTPS_URL/CLASSPATH_URL).
  3. Add the missing copy() overrides; add result.ifExists = ifExists; to DropIndexStatement,
    result.skip = ... to TraverseStatement, result.returnCount = returnCount; to
    UpdateStatement.

Scope / confidence

Rated low because top-level Statement.copy() has no caller outside the parser package today
(verified by grep), so item 3 is latent; items 1 and 2 are live rendering defects but on statements
that are rarely re-rendered. The TraverseStatement/UpdateStatement gaps were found by a scripted
field-vs-copy()/getIdentityElements() diff over all 228 parser classes (script inline in the session
log); the remaining hits from that diff were constants and false positives, and the only substantive
ones outside this bundle are the AlterTypeStatement and CreateIndexStatement findings above.

Activity

  1. added
    engine
    on Sep 17, 2026
  2. added this to the 26.10.1 milestone on Sep 17, 2026
  3. added
    in progress
    on Sep 17, 2026
  4. self-assigned this
    on Sep 17, 2026
  5. added a commit that references this issue on Sep 17, 2026
  6. lvca commented on Sep 17, 2026

    @lvca
    Member

    Fixed in #7813 (merged).

    Two things:

    1. CREATE MATERIALIZED VIEW ... REFRESH EVERY n SECOND/MINUTE/HOUR now prints back as valid SQL again (it used to print an extra PERIODIC word that doesn't exist in the SQL grammar).
    2. BACKUP/EXPORT DATABASE with a quoted file path (e.g. 'my backup.zip') now keeps its quotes when the statement is re-rendered internally, instead of losing them.

    Also fixed several other DDL statements (materialized views, graph analytical views, continuous aggregates, CHECK DATABASE, ALIGN DATABASE) that failed with an internal error when the engine needed to duplicate them internally (used for statement caching).


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugenginesql

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions