jovanpop-msft's avatar
jovanpop-msft
Icon for Microsoft Employee rankMicrosoft Employee
22 days ago
Status:
New

:: operator for typecast in T-SQL

Introduce support for the ::type cast operator in Fabric Data Warehouse as syntactic sugar for the existing CAST(... AS type) expression. The new operator would be functionally equivalent and compile to the same internal representation, providing a more concise and familiar syntax for users coming from PostgreSQL, Snowflake, Databricks, and other modern SQL engines:

Examples

SELECT '123'::INT;
SELECT order_date::DATE;
SELECT total_amount::DECIMAL(10,2);

Benefits

  • Reduces verbosity for common type conversions.
  • Improves developer productivity and query readability.
  • Aligns Fabric DW with widely adopted SQL dialects that already support ::type.
  • Low-risk addition because it is purely syntactic and can be translated internally to existing CAST semantics.

2 Comments

  • Casting to dates, would like it to be able to take a format, culture

  • No, it should be syntactic sugar for CAST/CONVERT. It should be syntactic sugar for TRY_CAST/TRY_CONVERT. That is, a failed conversion should result in NULL, not an error. If not the operator is quite useless. 

Recent ideas