@@ -37,7 +37,7 @@ use crate::ast::{
3737 ValueWithSpan ,
3838} ;
3939use crate :: keywords:: Keyword ;
40- use crate :: tokenizer:: Token ;
40+ use crate :: tokenizer:: { Span , Token } ;
4141
4242/// An `ALTER TABLE` (`Statement::AlterTable`) operation
4343#[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
@@ -1655,6 +1655,20 @@ pub enum ColumnOption {
16551655 /// false if 'GENERATED ALWAYS' is skipped (option starts with AS)
16561656 generated_keyword : bool ,
16571657 } ,
1658+ /// `METADATA FROM 'key'`
1659+ ///
1660+ /// A special type of column that gets its value from metadata
1661+ /// associated with the record.
1662+ ///
1663+ /// Example:
1664+ /// ```sql
1665+ /// CREATE TABLE logs (
1666+ /// id TEXT,
1667+ /// kafka_topic STRING METADATA FROM 'topic',
1668+ /// log TEXT
1669+ /// )
1670+ /// ```
1671+ MetadataField ( String , Span ) ,
16581672 /// BigQuery specific: Explicit column options in a view [1] or table [2]
16591673 /// Syntax
16601674 /// ```sql
@@ -1745,6 +1759,7 @@ impl fmt::Display for ColumnOption {
17451759 Collation ( n) => write ! ( f, "COLLATE {n}" ) ,
17461760 Comment ( v) => write ! ( f, "COMMENT '{}'" , escape_single_quote_string( v) ) ,
17471761 OnUpdate ( expr) => write ! ( f, "ON UPDATE {expr}" ) ,
1762+ MetadataField ( key, _) => write ! ( f, "METADATA FROM '{}'" , escape_single_quote_string( key) ) ,
17481763 Generated {
17491764 generated_as,
17501765 sequence_options,
0 commit comments