You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/08/23 15:42:09 UTC

[GitHub] [arrow] wqc200 opened a new pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

wqc200 opened a new pull request #8033:
URL: https://github.com/apache/arrow/pull/8033


   Select @@version;
   
   @@version is a variable, and if we want to get its value, we should get it from outside the system,


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jorgecarleitao commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r475270454



##########
File path: rust/datafusion/src/variable/system.rs
##########
@@ -0,0 +1,18 @@
+use crate::logicalplan::ScalarValue;
+use crate::error::Result;
+use crate::variable::VariableProvider;
+
+pub struct SystemVariable {}
+
+impl SystemVariable {
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl VariableProvider for SystemVariable {
+    fn get_value(&self, variable_names: Vec<String>) -> Result<ScalarValue> {
+        let s = format!("{}-{}", "test".to_string(), variable_names.concat());

Review comment:
       why `test`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] andygrove commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
andygrove commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r483010491



##########
File path: rust/datafusion/src/variable/system.rs
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! System variable provider
+
+use crate::error::Result;
+use crate::logicalplan::ScalarValue;
+use crate::variable::VarProvider;
+
+/// System variable
+pub struct SystemVar {}
+
+impl SystemVar {
+    /// new system variable
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl VarProvider for SystemVar {
+    /// get system variable value
+    fn get_value(&self, var_names: Vec<String>) -> Result<ScalarValue> {
+        let s = format!("{}-{}", "test".to_string(), var_names.concat());

Review comment:
       This seems to be test code but is not marked with `#[test]` as far as I can see.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 closed pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 closed pull request #8033:
URL: https://github.com/apache/arrow/pull/8033


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 closed pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 closed pull request #8033:
URL: https://github.com/apache/arrow/pull/8033


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r483668849



##########
File path: rust/datafusion/src/variable/user_defined.rs
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! User defined variable provider
+
+use crate::error::Result;
+use crate::logicalplan::ScalarValue;
+use crate::variable::VarProvider;
+
+/// user defined variable
+pub struct UserDefinedVar {}

Review comment:
       Yes, I move it to test dir

##########
File path: rust/datafusion/src/variable/system.rs
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! System variable provider
+
+use crate::error::Result;
+use crate::logicalplan::ScalarValue;
+use crate::variable::VarProvider;
+
+/// System variable
+pub struct SystemVar {}
+
+impl SystemVar {
+    /// new system variable
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl VarProvider for SystemVar {
+    /// get system variable value
+    fn get_value(&self, var_names: Vec<String>) -> Result<ScalarValue> {
+        let s = format!("{}-{}", "test".to_string(), var_names.concat());

Review comment:
       Yes, I move it to test dir




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] andygrove commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
andygrove commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r483009108



##########
File path: rust/datafusion/src/variable/user_defined.rs
##########
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! User defined variable provider
+
+use crate::error::Result;
+use crate::logicalplan::ScalarValue;
+use crate::variable::VarProvider;
+
+/// user defined variable
+pub struct UserDefinedVar {}

Review comment:
       This seems to be identical to `SystemVar`. I understand that we want to register separate variables for user-defined and system, but I don't think we need two separate implementations of the trait?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] andygrove commented on pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
andygrove commented on pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#issuecomment-679429920


   Hi @wqc200 please rebase against master rather than merge from master once this is ready for review.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r478504215



##########
File path: rust/datafusion/src/logicalplan.rs
##########
@@ -713,6 +718,9 @@ impl fmt::Debug for Expr {
         match self {
             Expr::Alias(expr, alias) => write!(f, "{:?} AS {}", expr, alias),
             Expr::Column(name) => write!(f, "#{}", name),
+            Expr::ScalarVariable(variable_names) => {
+                write!(f, "#{}", variable_names.join("."))

Review comment:
       Yes, i remove the code '#', the variable name itself start with an @ sign




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] jorgecarleitao commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
jorgecarleitao commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r475270612



##########
File path: rust/datafusion/src/logicalplan.rs
##########
@@ -713,6 +718,9 @@ impl fmt::Debug for Expr {
         match self {
             Expr::Alias(expr, alias) => write!(f, "{:?} AS {}", expr, alias),
             Expr::Column(name) => write!(f, "#{}", name),
+            Expr::ScalarVariable(variable_names) => {
+                write!(f, "#{}", variable_names.join("."))

Review comment:
       this naming is already being used by columns (one line above). Doesn't this make it confusing?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] github-actions[bot] commented on pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#issuecomment-678790001


   https://issues.apache.org/jira/browse/ARROW-9837


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 commented on a change in pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 commented on a change in pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#discussion_r476572025



##########
File path: rust/datafusion/src/variable/system.rs
##########
@@ -0,0 +1,18 @@
+use crate::logicalplan::ScalarValue;
+use crate::error::Result;
+use crate::variable::VariableProvider;
+
+pub struct SystemVariable {}
+
+impl SystemVariable {
+    pub fn new() -> Self {
+        Self {}
+    }
+}
+
+impl VariableProvider for SystemVariable {
+    fn get_value(&self, variable_names: Vec<String>) -> Result<ScalarValue> {
+        let s = format!("{}-{}", "test".to_string(), variable_names.concat());

Review comment:
       When the user USES, to create a new system and user_defined method, here is only for the user to understand.
   The @@ variable is defined by the external system




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] andygrove commented on pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
andygrove commented on pull request #8033:
URL: https://github.com/apache/arrow/pull/8033#issuecomment-688500627


   @wqc200 Thanks for making those changes. However, I still see merges in the commit history for this PR. I would suggest creating a new PR from master with these approved changes if you are not comfortable with rebasing this PR. 
   
   See this article for more information about rebasing: https://andygrove.io/apache_arrow_git_tips/


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow] wqc200 closed pull request #8033: ARROW-9837: [Rust][DataFusion] Add provider for variable

Posted by GitBox <gi...@apache.org>.
wqc200 closed pull request #8033:
URL: https://github.com/apache/arrow/pull/8033


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org