You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/23 06:14:11 UTC
[GitHub] [spark] beliefer opened a new pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
beliefer opened a new pull request #35947:
URL: https://github.com/apache/spark/pull/35947
### What changes were proposed in this pull request?
Cast is very useful and Spark always use Cast to convert data type automatically.
### Why are the changes needed?
Let more aggregates and filters could be pushed down.
### Does this PR introduce _any_ user-facing change?
'Yes'.
This PR after 3.3.0 cut off.
### How was this patch tested?
New tests.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] beliefer commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
beliefer commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836080093
##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Cast.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.spark.sql.connector.expressions;
+
+import org.apache.spark.annotation.Evolving;
+import org.apache.spark.sql.types.DataType;
+
+/**
+ * Represents a cast expression in the public logical expression API.
+ *
+ * @since 3.4.0
Review comment:
OK
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #35947:
URL: https://github.com/apache/spark/pull/35947
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] beliefer commented on pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
beliefer commented on pull request #35947:
URL: https://github.com/apache/spark/pull/35947#issuecomment-1076214918
ping @huaxingao cc @cloud-fan
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836066731
##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Cast.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.spark.sql.connector.expressions;
+
+import org.apache.spark.annotation.Evolving;
+import org.apache.spark.sql.types.DataType;
+
+/**
+ * Represents a cast expression in the public logical expression API.
+ *
+ * @since 3.4.0
Review comment:
CAST is a very common expression and I'd support including it in 3.3 as part of the DS v2 pushdown improvement project.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] beliefer commented on pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
beliefer commented on pull request #35947:
URL: https://github.com/apache/spark/pull/35947#issuecomment-1081365376
@cloud-fan Thank you
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836065860
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCV2Suite.scala
##########
@@ -446,6 +446,25 @@ class JDBCV2Suite extends QueryTest with SharedSparkSession with ExplainSuiteHel
checkAnswer(df3,
Seq(Row(1, "cathy", 9000, 1200, false), Row(2, "david", 10000, 1300, true)))
+
+ val df4 = spark.table("h2.test.employee")
+ .filter(($"salary" > 1000d).and($"salary" < 12000d))
+
+ checkFiltersRemoved(df4, ansiMode)
+
+ df4.queryExecution.optimizedPlan.collect {
+ case _: DataSourceV2ScanRelation =>
+ val expected_plan_fragment = if (ansiMode) {
+ "PushedFilters: [SALARY IS NOT NULL, " +
+ "CAST( SALARY AS double ) > 1000.0, CAST( SALARY AS double ) < 12000.0], "
Review comment:
We shouldn't put spaces around `CAST( ... )`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] beliefer commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
beliefer commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836197814
##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/GeneralScalarExpression.java
##########
@@ -28,7 +28,7 @@
/**
* The general representation of SQL scalar expressions, which contains the upper-cased
* expression name and all the children expressions. Please also see {@link Predicate}
- * for the supported predicate expressions.
+ * for the supported predicate expressions and {@link Cast} for the cast expression.
Review comment:
Yeah.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836066452
##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/Cast.java
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.spark.sql.connector.expressions;
+
+import org.apache.spark.annotation.Evolving;
+import org.apache.spark.sql.types.DataType;
+
+/**
+ * Represents a cast expression in the public logical expression API.
+ *
+ * @since 3.4.0
+ */
+@Evolving
+public class Cast extends GeneralScalarExpression {
Review comment:
Does it need to extend `GeneralScalarExpression`? I think extending `Expression` should be good enough, similar to `SortOrder`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35947:
URL: https://github.com/apache/spark/pull/35947#discussion_r836194471
##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/GeneralScalarExpression.java
##########
@@ -28,7 +28,7 @@
/**
* The general representation of SQL scalar expressions, which contains the upper-cased
* expression name and all the children expressions. Please also see {@link Predicate}
- * for the supported predicate expressions.
+ * for the supported predicate expressions and {@link Cast} for the cast expression.
Review comment:
We don't need this change now.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #35947: [SPARK-38633][SQL] Support push down Cast to JDBC data source V2
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #35947:
URL: https://github.com/apache/spark/pull/35947#issuecomment-1081361454
thanks, merging to master/3.3!
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org