Skip to content

Incorrect backslash treatment in string literals in DataFusion CLI #13286

Closed
@findepi

Description

@findepi

In standard SQL, the \ character has no special meaning in '...' varchar literals.

In PostgreSQL

postgres=# SELECT '\', '\\'
postgres-# ;
 ?column? | ?column?
----------+----------
 \        | \\
(1 row)

in DataFusion sqllogictest the behavior is the same:

query T
SELECT '\'
----
\

query T
SELECT '\\'
----
\\

query T
SELECT '\\\'
----
\\\

query T
SELECT '\\\\'
----
\\\\

However, DataFusion CLI behaves differently

$ cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/datafusion-cli`
DataFusion CLI v43.0.0
> SELECT '\\';
+-----------+
| Utf8("\") |
+-----------+
| \         |
+-----------+
1 row(s) fetched.
Elapsed 0.049 seconds.

> SELECT '\';  🤔 Invalid statement: SQL error: TokenizerError("unsupported escape char: '\\''")

Given that DataFusion CLI is used a lot to test and verify DataFusion's behavior, it's super important for the CLI to behave correctly with respect to its input.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions