42 minutes ago · 14 min read2882 words · Tech · hide

Load the polyglot extension, select a dialect, and DuckDB executes T-SQL, MySQL, PostgreSQL, BigQuery or Snowflake SQL as it is. No function call around the query, no rewrite in the application. In February I introduced polyglot, a Rust library that transpiles SQL between dialects. The DuckDB polyglot extension brings that library into DuckDB. Until now it worked through functions: you passed your SQL as a string to polyglot_transpile() or polyglot_query(), together with the dialect it was written in. Version 0.7.0 removes the string. A connection can now declare an input dialect, and from then on every statement it sends is translated to DuckDB SQL inside DuckDB’s parser and executed right away: INSTALL AND LOAD polyglot FROM tobilg; SET SESSION allow_parser_override_extension = 'strict'; SET SESSION polyglot_input_dialect = 'tsql'; SELECT TOP 2 n FROM (VALUES (3), (1), (2)) AS t(n) ORDER BY n; ┌───┐ │ n │ ├───┤ │ 1 │ │ 2 │ └───┘ That’s T-SQL, typed into a DuckDB shell. This post…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town