Skip to content

sql: refuse names that shadow a registered table, and drop the LIKE type and escape conditions #3026

Open

Description

@pmoust

Part of epic #2904. Follow-up to #2909 (PR #3003), carried from comments on #2910.

Problem. In a session that registers logs beside another table, LikeScope::LogsColumnsOnly (crates/ravel-sql/src/like_udf.rs) rewrites a LIKE to the dictionary-aware UDF only when four things hold:

  • its columns are qualified logs;
  • its operands are string typed;
  • its escape is absent or a backslash;
  • it has no outer reference.

The type and escape conditions are there because the rewrite's DFSchema carries only the qualifier name, so FROM samples AS logs passes the qualifier test.

The cost: a genuine logs predicate with a custom ESCAPE, or with a non-string operand (for example a declared Int64 column LIKE '4%'), is refused in a multi-table statement, while the same predicate runs in a logs-only statement. ADR-2904's LIKE-scope amendment records this.

A second gap: references_only_logs_columns and references_outer_columns treat an Expr::ScalarSubquery operand as a leaf. The subquery's own columns and its correlated outer references are not seen. The outcome holds today, because the type and escape conditions still apply. But the LogsColumnsOnly doc and the ADR amendment say "every column its operands reference".

Change.

  1. In a multi-table statement, refuse a relation alias, derived table or CTE whose name shadows a registered table name. The refusal is a typed plan error before any listing.
  2. With the qualifier test exact, drop the type and escape conditions from LikeScope::LogsColumnsOnly, so a genuine logs LIKE behaves the same with or without another table.
  3. Either make the column walk enter subquery operands, or narrow the doc and the ADR amendment to the operands' own columns.
  4. Update the ADR-2904 LIKE-scope amendment to match.

Acceptance.

  • A custom-escape logs LIKE beside samples runs and matches the logs-only result.
  • FROM samples AS logs in a two-table statement is refused.
  • the_dictionary_probe_wraps_the_same_functions_in_a_two_table_session still passes.

Depends on: #2910, because its multi-signal path is what makes the refusal reachable. Must land before the epic closes.

Activity

  1. self-assigned this
    on Oct 15, 2026
  2. pmoust commented on Oct 19, 2026

    @pmoust
    MemberAuthor

    Since #2914 (PR #3107), a statement may name a Parquet table beside logs. Such a session registers two tables, so it takes LikeScope::LogsColumnsOnly, and a genuine logs LIKE with a custom escape or a non-string operand is refused there, as it is beside samples. When this ticket drops the type and escape conditions, cover the Parquet shape in its test as well. For example, SELECT ... FROM logs JOIN hits ... WHERE logs.body LIKE 'a!_b' ESCAPE '!' should answer as the logs-only statement does.

    Also make the shadowing refusal cover a relation alias that shadows a registered Parquet table name.

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

Metadata

Metadata

Assignees

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