1- use crate :: { compile:: CubeContext , CubeError } ;
1+ use crate :: {
2+ compile:: { CubeContext , DatabaseVariable , DatabaseVariables } ,
3+ CubeError ,
4+ } ;
25use datafusion:: datasource;
6+ use log:: error;
37use std:: {
48 fmt:: Debug ,
59 hash:: { Hash , Hasher } ,
@@ -13,11 +17,17 @@ pub trait DatabaseProtocolDetails: Debug + Send + Sync {
1317
1418 fn support_transactions ( & self ) -> bool ;
1519
20+ /// Get default state for session variables
21+ fn get_session_default_variables ( & self ) -> DatabaseVariables ;
22+
23+ /// Get default value for specific session variable
24+ fn get_session_variable_default ( & self , name : & str ) -> Option < DatabaseVariable > ;
25+
1626 fn get_provider (
1727 & self ,
1828 context : & CubeContext ,
1929 tr : datafusion:: catalog:: TableReference ,
20- ) -> Option < std :: sync :: Arc < dyn datasource:: TableProvider > > ;
30+ ) -> Option < Arc < dyn datasource:: TableProvider > > ;
2131
2232 fn table_name_by_table_provider (
2333 & self ,
@@ -70,6 +80,28 @@ impl DatabaseProtocolDetails for DatabaseProtocol {
7080 }
7181 }
7282
83+ fn get_session_default_variables ( & self ) -> DatabaseVariables {
84+ match & self {
85+ DatabaseProtocol :: MySQL => {
86+ // TODO(ovr): Should we move it from session?
87+ error ! ( "get_session_default_variables was called on MySQL protocol" ) ;
88+
89+ DatabaseVariables :: default ( )
90+ }
91+ DatabaseProtocol :: PostgreSQL => {
92+ // TODO(ovr): Should we move it from session?
93+ error ! ( "get_session_default_variables was called on PostgreSQL protocol" ) ;
94+
95+ DatabaseVariables :: default ( )
96+ }
97+ DatabaseProtocol :: Extension ( ext) => ext. get_session_default_variables ( ) ,
98+ }
99+ }
100+
101+ fn get_session_variable_default ( & self , name : & str ) -> Option < DatabaseVariable > {
102+ self . get_session_default_variables ( ) . get ( name) . cloned ( )
103+ }
104+
73105 fn get_provider (
74106 & self ,
75107 context : & CubeContext ,
0 commit comments