From 8b2154db295b062be9c284e8cf1734b579ec4c98 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Thu, 20 Apr 2023 23:11:51 +0200 Subject: [PATCH 1/3] feat: add version field to SessionState --- datafusion/core/src/execution/context.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs index d25f96f649043..f9ba704117289 100644 --- a/datafusion/core/src/execution/context.rs +++ b/datafusion/core/src/execution/context.rs @@ -1235,6 +1235,8 @@ pub struct SessionState { table_factories: HashMap>, /// Runtime environment runtime_env: Arc, + /// Version of the cargo package that produced this query + version: String, } impl Debug for SessionState { @@ -1361,6 +1363,7 @@ impl SessionState { execution_props: ExecutionProps::new(), runtime_env: runtime, table_factories, + version: env!("CARGO_PKG_VERSION").to_string(), } } @@ -1803,6 +1806,11 @@ impl SessionState { pub fn aggregate_functions(&self) -> &HashMap> { &self.aggregate_functions } + + /// Return version + pub fn version(&self) -> &str { + &self.version + } } struct SessionContextProvider<'a> { From 3c7d93195f13b33b9a4d7fe3f982530f491f3051 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 21 Apr 2023 22:43:49 +0200 Subject: [PATCH 2/3] simplify code --- datafusion/core/src/execution/context.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs index f9ba704117289..1438d99ae8a4e 100644 --- a/datafusion/core/src/execution/context.rs +++ b/datafusion/core/src/execution/context.rs @@ -1235,8 +1235,6 @@ pub struct SessionState { table_factories: HashMap>, /// Runtime environment runtime_env: Arc, - /// Version of the cargo package that produced this query - version: String, } impl Debug for SessionState { @@ -1363,7 +1361,6 @@ impl SessionState { execution_props: ExecutionProps::new(), runtime_env: runtime, table_factories, - version: env!("CARGO_PKG_VERSION").to_string(), } } @@ -1809,7 +1806,7 @@ impl SessionState { /// Return version pub fn version(&self) -> &str { - &self.version + env!("CARGO_PKG_VERSION") } } From f4231535c26302c886f1b3c715286f8e9a0ac075 Mon Sep 17 00:00:00 2001 From: Weijun Huang Date: Fri, 21 Apr 2023 22:45:12 +0200 Subject: [PATCH 3/3] add comment --- datafusion/core/src/execution/context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/core/src/execution/context.rs b/datafusion/core/src/execution/context.rs index 1438d99ae8a4e..c06a71a6ac09b 100644 --- a/datafusion/core/src/execution/context.rs +++ b/datafusion/core/src/execution/context.rs @@ -1804,7 +1804,7 @@ impl SessionState { &self.aggregate_functions } - /// Return version + /// Return version of the cargo package that produced this query pub fn version(&self) -> &str { env!("CARGO_PKG_VERSION") }