zed icon indicating copy to clipboard operation
zed copied to clipboard

SQL: Support for "::" casting notation

Open philrz opened this issue 8 months ago • 0 comments

tl;dr

$ super -c "SELECT 3::string"
parse error at line 1, column 11:
SELECT 3::string
      === ^ ===

Details

Repro is with super commit cabf51f. This is a query from a sqllogictest.

SuperDB currently has a couple supported syntaxes for type casting, e.g.,

$ super -version
Version: cabf51f1a

$ super -c "SELECT string(3);"
{"string(3)":"3"}

$ super -c "SELECT CAST(3 AS string);"
{"CAST(3 AS string)":"3"}

However, the following syntax (allegedly first popularized by Postgres) is not currently supported.

$ super -c "SELECT 3::string"
parse error at line 1, column 11:
SELECT 3::string
      === ^ ===

An example of another SQL system that supports it:

$ duckdb --version
v1.3.0 71c5c07cdd

$ duckdb -c "SELECT 3::string"
┌────────────────────┐
│ CAST(3 AS VARCHAR) │
│      varchar       │
├────────────────────┤
│ 3                  │
└────────────────────┘

philrz avatar Jun 17 '25 02:06 philrz