@@ -30,7 +30,7 @@ use crate::{
3030} ;
3131use datafusion_common:: {
3232 alias:: AliasGenerator ,
33- exec_err, not_impl_err, plan_err,
33+ exec_err, not_impl_err, plan_datafusion_err , plan_err,
3434 tree_node:: { TreeNode , TreeNodeVisitor , VisitRecursion } ,
3535} ;
3636use datafusion_execution:: registry:: SerializerRegistry ;
@@ -1577,17 +1577,14 @@ impl SessionState {
15771577 self . catalog_list
15781578 . catalog ( & resolved_ref. catalog )
15791579 . ok_or_else ( || {
1580- DataFusionError :: Plan ( format ! (
1580+ plan_datafusion_err ! (
15811581 "failed to resolve catalog: {}" ,
15821582 resolved_ref. catalog
1583- ) )
1583+ )
15841584 } ) ?
15851585 . schema ( & resolved_ref. schema )
15861586 . ok_or_else ( || {
1587- DataFusionError :: Plan ( format ! (
1588- "failed to resolve schema: {}" ,
1589- resolved_ref. schema
1590- ) )
1587+ plan_datafusion_err ! ( "failed to resolve schema: {}" , resolved_ref. schema)
15911588 } )
15921589 }
15931590
@@ -1689,11 +1686,11 @@ impl SessionState {
16891686 dialect : & str ,
16901687 ) -> Result < datafusion_sql:: parser:: Statement > {
16911688 let dialect = dialect_from_str ( dialect) . ok_or_else ( || {
1692- DataFusionError :: Plan ( format ! (
1689+ plan_datafusion_err ! (
16931690 "Unsupported SQL dialect: {dialect}. Available dialects: \
16941691 Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, \
16951692 MsSQL, ClickHouse, BigQuery, Ansi."
1696- ) )
1693+ )
16971694 } ) ?;
16981695 let mut statements = DFParser :: parse_sql_with_dialect ( sql, dialect. as_ref ( ) ) ?;
16991696 if statements. len ( ) > 1 {
@@ -2022,7 +2019,7 @@ impl<'a> ContextProvider for SessionContextProvider<'a> {
20222019 self . tables
20232020 . get ( & name)
20242021 . cloned ( )
2025- . ok_or_else ( || DataFusionError :: Plan ( format ! ( "table '{name}' not found" ) ) )
2022+ . ok_or_else ( || plan_datafusion_err ! ( "table '{name}' not found" ) )
20262023 }
20272024
20282025 fn get_function_meta ( & self , name : & str ) -> Option < Arc < ScalarUDF > > {
@@ -2069,29 +2066,23 @@ impl FunctionRegistry for SessionState {
20692066 let result = self . scalar_functions . get ( name) ;
20702067
20712068 result. cloned ( ) . ok_or_else ( || {
2072- DataFusionError :: Plan ( format ! (
2073- "There is no UDF named \" {name}\" in the registry"
2074- ) )
2069+ plan_datafusion_err ! ( "There is no UDF named \" {name}\" in the registry" )
20752070 } )
20762071 }
20772072
20782073 fn udaf ( & self , name : & str ) -> Result < Arc < AggregateUDF > > {
20792074 let result = self . aggregate_functions . get ( name) ;
20802075
20812076 result. cloned ( ) . ok_or_else ( || {
2082- DataFusionError :: Plan ( format ! (
2083- "There is no UDAF named \" {name}\" in the registry"
2084- ) )
2077+ plan_datafusion_err ! ( "There is no UDAF named \" {name}\" in the registry" )
20852078 } )
20862079 }
20872080
20882081 fn udwf ( & self , name : & str ) -> Result < Arc < WindowUDF > > {
20892082 let result = self . window_functions . get ( name) ;
20902083
20912084 result. cloned ( ) . ok_or_else ( || {
2092- DataFusionError :: Plan ( format ! (
2093- "There is no UDWF named \" {name}\" in the registry"
2094- ) )
2085+ plan_datafusion_err ! ( "There is no UDWF named \" {name}\" in the registry" )
20952086 } )
20962087 }
20972088}
0 commit comments