You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jdye64 (via GitHub)" <gi...@apache.org> on 2023/03/12 19:35:54 UTC

[GitHub] [arrow-datafusion-python] jdye64 opened a new pull request, #269: Subquery alias bindings

jdye64 opened a new pull request, #269:
URL: https://github.com/apache/arrow-datafusion-python/pull/269

   # Which issue does this PR close?
   
   Closes #268 


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion-python] andygrove commented on a diff in pull request #269: Subquery alias bindings

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on code in PR #269:
URL: https://github.com/apache/arrow-datafusion-python/pull/269#discussion_r1134382303


##########
src/expr/subquery_alias.rs:
##########
@@ -0,0 +1,91 @@
+// 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.
+
+use std::fmt::{self, Display, Formatter};
+
+use datafusion_expr::SubqueryAlias;
+use pyo3::prelude::*;
+
+use crate::{common::df_schema::PyDFSchema, sql::logical::PyLogicalPlan};
+
+use super::logical_node::LogicalNode;
+
+#[pyclass(name = "SubqueryAlias", module = "datafusion.expr", subclass)]
+#[derive(Clone)]
+pub struct PySubqueryAlias {
+    subquery_alias: SubqueryAlias,
+}
+
+impl From<PySubqueryAlias> for SubqueryAlias {
+    fn from(subquery_alias: PySubqueryAlias) -> Self {
+        subquery_alias.subquery_alias
+    }
+}
+
+impl From<SubqueryAlias> for PySubqueryAlias {
+    fn from(subquery_alias: SubqueryAlias) -> PySubqueryAlias {
+        PySubqueryAlias { subquery_alias }
+    }
+}
+
+impl Display for PySubqueryAlias {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        write!(
+            f,
+            "SubqueryAlias
+            \nInputs(s): {:?}
+            \nAlias: {:?}
+            \nSchema: {:?}",
+            self.subquery_alias.input, self.subquery_alias.alias, self.subquery_alias.schema,
+        )
+    }
+}
+
+#[pymethods]
+impl PySubqueryAlias {
+    /// Retrieves the input `LogicalPlan` to this `Projection` node
+    fn input(&self) -> PyResult<Vec<PyLogicalPlan>> {
+        Ok(Self::inputs(self))
+    }
+
+    /// Resulting Schema for this `Projection` node instance
+    fn schema(&self) -> PyResult<PyDFSchema> {
+        Ok((*self.subquery_alias.schema).clone().into())
+    }
+
+    fn alias(&self) -> PyResult<String> {
+        Ok(self.subquery_alias.alias.clone())
+    }
+
+    fn __repr__(&self) -> PyResult<String> {
+        Ok(format!("Projection({})", self))

Review Comment:
   looks incorrect?



##########
src/expr/subquery_alias.rs:
##########
@@ -0,0 +1,91 @@
+// 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.
+
+use std::fmt::{self, Display, Formatter};
+
+use datafusion_expr::SubqueryAlias;
+use pyo3::prelude::*;
+
+use crate::{common::df_schema::PyDFSchema, sql::logical::PyLogicalPlan};
+
+use super::logical_node::LogicalNode;
+
+#[pyclass(name = "SubqueryAlias", module = "datafusion.expr", subclass)]
+#[derive(Clone)]
+pub struct PySubqueryAlias {
+    subquery_alias: SubqueryAlias,
+}
+
+impl From<PySubqueryAlias> for SubqueryAlias {
+    fn from(subquery_alias: PySubqueryAlias) -> Self {
+        subquery_alias.subquery_alias
+    }
+}
+
+impl From<SubqueryAlias> for PySubqueryAlias {
+    fn from(subquery_alias: SubqueryAlias) -> PySubqueryAlias {
+        PySubqueryAlias { subquery_alias }
+    }
+}
+
+impl Display for PySubqueryAlias {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        write!(
+            f,
+            "SubqueryAlias
+            \nInputs(s): {:?}
+            \nAlias: {:?}
+            \nSchema: {:?}",
+            self.subquery_alias.input, self.subquery_alias.alias, self.subquery_alias.schema,
+        )
+    }
+}
+
+#[pymethods]
+impl PySubqueryAlias {
+    /// Retrieves the input `LogicalPlan` to this `Projection` node
+    fn input(&self) -> PyResult<Vec<PyLogicalPlan>> {
+        Ok(Self::inputs(self))
+    }
+
+    /// Resulting Schema for this `Projection` node instance
+    fn schema(&self) -> PyResult<PyDFSchema> {
+        Ok((*self.subquery_alias.schema).clone().into())
+    }
+
+    fn alias(&self) -> PyResult<String> {
+        Ok(self.subquery_alias.alias.clone())
+    }
+
+    fn __repr__(&self) -> PyResult<String> {
+        Ok(format!("Projection({})", self))
+    }
+
+    fn __name__(&self) -> PyResult<String> {
+        Ok("Projection".to_string())

Review Comment:
   here too



-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion-python] andygrove commented on pull request #269: Subquery alias bindings

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #269:
URL: https://github.com/apache/arrow-datafusion-python/pull/269#issuecomment-1466419008

   > @andygrove do we have an keyword to "rerun tests" here? Seems like an action failed just simply from a http timeout and want to rerun it without making a silly empty commit.
   
   No, but any committer can manually restart failed jobs via the GitHub UI.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion-python] jdye64 commented on pull request #269: Subquery alias bindings

Posted by "jdye64 (via GitHub)" <gi...@apache.org>.
jdye64 commented on PR #269:
URL: https://github.com/apache/arrow-datafusion-python/pull/269#issuecomment-1465324306

   @andygrove do we have an keyword to "rerun tests" here? Seems like an action failed just simply from a http timeout and want to rerun it without making a silly empty commit.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion-python] andygrove merged pull request #269: Subquery alias bindings

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #269:
URL: https://github.com/apache/arrow-datafusion-python/pull/269


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

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