@@ -46,7 +46,13 @@ use datafusion_common::{
4646use datafusion_expr_common:: placement:: ExpressionPlacement ;
4747use datafusion_functions_window_common:: field:: WindowUDFFieldArgs ;
4848#[ cfg( feature = "sql" ) ]
49- use sqlparser:: ast:: {
49+ pub use sqlparser:: ast:: {
50+ ExceptSelectItem , ExcludeSelectItem , IlikeSelectItem , RenameSelectItem ,
51+ ReplaceSelectElement ,
52+ } ;
53+ // Use shims for sqlparser types when the sql feature is disabled.
54+ #[ cfg( not( feature = "sql" ) ) ]
55+ pub use crate :: sql:: {
5056 ExceptSelectItem , ExcludeSelectItem , IlikeSelectItem , RenameSelectItem ,
5157 ReplaceSelectElement ,
5258} ;
@@ -1416,63 +1422,6 @@ impl Lambda {
14161422 }
14171423}
14181424
1419- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1420- #[ cfg( not( feature = "sql" ) ) ]
1421- pub struct IlikeSelectItem {
1422- pub pattern : String ,
1423- }
1424- #[ cfg( not( feature = "sql" ) ) ]
1425- impl Display for IlikeSelectItem {
1426- fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
1427- write ! ( f, "ILIKE '{}'" , & self . pattern) ?;
1428- Ok ( ( ) )
1429- }
1430- }
1431- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1432- #[ cfg( not( feature = "sql" ) ) ]
1433- pub enum ExcludeSelectItem {
1434- Single ( Ident ) ,
1435- Multiple ( Vec < Ident > ) ,
1436- }
1437- #[ cfg( not( feature = "sql" ) ) ]
1438- impl Display for ExcludeSelectItem {
1439- fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
1440- write ! ( f, "EXCLUDE" ) ?;
1441- match self {
1442- Self :: Single ( column) => {
1443- write ! ( f, " {column}" ) ?;
1444- }
1445- Self :: Multiple ( columns) => {
1446- write ! ( f, " ({})" , display_comma_separated( columns) ) ?;
1447- }
1448- }
1449- Ok ( ( ) )
1450- }
1451- }
1452- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1453- #[ cfg( not( feature = "sql" ) ) ]
1454- pub struct ExceptSelectItem {
1455- pub first_element : Ident ,
1456- pub additional_elements : Vec < Ident > ,
1457- }
1458- #[ cfg( not( feature = "sql" ) ) ]
1459- impl Display for ExceptSelectItem {
1460- fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
1461- write ! ( f, "EXCEPT " ) ?;
1462- if self . additional_elements . is_empty ( ) {
1463- write ! ( f, "({})" , self . first_element) ?;
1464- } else {
1465- write ! (
1466- f,
1467- "({}, {})" ,
1468- self . first_element,
1469- display_comma_separated( & self . additional_elements)
1470- ) ?;
1471- }
1472- Ok ( ( ) )
1473- }
1474- }
1475-
14761425pub fn display_comma_separated < T > ( slice : & [ T ] ) -> String
14771426where
14781427 T : Display ,
@@ -1481,64 +1430,6 @@ where
14811430 slice. iter ( ) . map ( |v| format ! ( "{v}" ) ) . join ( ", " )
14821431}
14831432
1484- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1485- #[ cfg( not( feature = "sql" ) ) ]
1486- pub enum RenameSelectItem {
1487- Single ( String ) ,
1488- Multiple ( Vec < String > ) ,
1489- }
1490- #[ cfg( not( feature = "sql" ) ) ]
1491- impl Display for RenameSelectItem {
1492- fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
1493- write ! ( f, "RENAME" ) ?;
1494- match self {
1495- Self :: Single ( column) => {
1496- write ! ( f, " {column}" ) ?;
1497- }
1498- Self :: Multiple ( columns) => {
1499- write ! ( f, " ({})" , display_comma_separated( columns) ) ?;
1500- }
1501- }
1502- Ok ( ( ) )
1503- }
1504- }
1505-
1506- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1507- #[ cfg( not( feature = "sql" ) ) ]
1508- pub struct Ident {
1509- /// The value of the identifier without quotes.
1510- pub value : String ,
1511- /// The starting quote if any. Valid quote characters are the single quote,
1512- /// double quote, backtick, and opening square bracket.
1513- pub quote_style : Option < char > ,
1514- /// The span of the identifier in the original SQL string.
1515- pub span : String ,
1516- }
1517- #[ cfg( not( feature = "sql" ) ) ]
1518- impl Display for Ident {
1519- fn fmt ( & self , f : & mut Formatter ) -> fmt:: Result {
1520- write ! ( f, "[{}]" , self . value)
1521- }
1522- }
1523-
1524- #[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug ) ]
1525- #[ cfg( not( feature = "sql" ) ) ]
1526- pub struct ReplaceSelectElement {
1527- pub expr : String ,
1528- pub column_name : Ident ,
1529- pub as_keyword : bool ,
1530- }
1531- #[ cfg( not( feature = "sql" ) ) ]
1532- impl Display for ReplaceSelectElement {
1533- fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
1534- if self . as_keyword {
1535- write ! ( f, "{} AS {}" , self . expr, self . column_name)
1536- } else {
1537- write ! ( f, "{} {}" , self . expr, self . column_name)
1538- }
1539- }
1540- }
1541-
15421433/// Additional options for wildcards, e.g. Snowflake `EXCLUDE`/`RENAME` and Bigquery `EXCEPT`.
15431434#[ derive( Clone , PartialEq , Eq , PartialOrd , Hash , Debug , Default ) ]
15441435pub struct WildcardOptions {
0 commit comments