@@ -329,6 +329,37 @@ impl fmt::Display for DictionaryField {
329329 }
330330}
331331
332+ /// Represents a Map expression.
333+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
334+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
335+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
336+ pub struct Map {
337+ pub entries : Vec < MapEntry > ,
338+ }
339+
340+ impl Display for Map {
341+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
342+ write ! ( f, "MAP {{{}}}" , display_comma_separated( & self . entries) )
343+ }
344+ }
345+
346+ /// A map field within a map.
347+ ///
348+ /// [duckdb]: https://duckdb.org/docs/sql/data_types/map.html#creating-maps
349+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
350+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
351+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
352+ pub struct MapEntry {
353+ pub key : Box < Expr > ,
354+ pub value : Box < Expr > ,
355+ }
356+
357+ impl fmt:: Display for MapEntry {
358+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
359+ write ! ( f, "{}: {}" , self . key, self . value)
360+ }
361+ }
362+
332363/// Options for `CAST` / `TRY_CAST`
333364/// BigQuery: <https://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#formatting_syntax>
334365#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
@@ -764,6 +795,14 @@ pub enum Expr {
764795 /// ```
765796 /// [1]: https://duckdb.org/docs/sql/data_types/struct#creating-structs
766797 Dictionary ( Vec < DictionaryField > ) ,
798+ /// `DuckDB` specific `Map` literal expression [1]
799+ ///
800+ /// Syntax:
801+ /// ```sql
802+ /// syntax: Map {key1: value1[, ... ]}
803+ /// ```
804+ /// [1]: https://duckdb.org/docs/sql/data_types/map#creating-maps
805+ Map ( Map ) ,
767806 /// An access of nested data using subscript syntax, for example `array[2]`.
768807 Subscript {
769808 expr : Box < Expr > ,
@@ -1331,6 +1370,9 @@ impl fmt::Display for Expr {
13311370 Expr :: Dictionary ( fields) => {
13321371 write ! ( f, "{{{}}}" , display_comma_separated( fields) )
13331372 }
1373+ Expr :: Map ( map) => {
1374+ write ! ( f, "{map}" )
1375+ }
13341376 Expr :: Subscript {
13351377 expr,
13361378 subscript : key,
0 commit comments