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 2023/01/14 01:20:49 UTC
[GitHub] [spark] huaxingao opened a new pull request, #39564: [SPARK-41990][SQL] Filrering by composite field name doesn't work
huaxingao opened a new pull request, #39564:
URL: https://github.com/apache/spark/pull/39564
### What changes were proposed in this pull request?
Use `FieldReference.column` instead of `FieldReference.apply` in V1 to V2 filter conversion
### Why are the changes needed?
bug fixing
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
UT
--
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] huaxingao commented on a diff in pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
huaxingao commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070860368
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala:
##########
@@ -1963,4 +1977,9 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-41990: Filter with composite name") {
+ val df = sql("SELECT * FROM composite_name WHERE `last name` = 'smith'")
Review Comment:
Right. Support for nested predicate pushdown is calculated by this [method](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceUtils.scala#L108), which returns false for JDBC V1.
--
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] huaxingao commented on pull request #39564: [SPARK-41990][SQL] Filrering by composite field name doesn't work
Posted by GitBox <gi...@apache.org>.
huaxingao commented on PR #39564:
URL: https://github.com/apache/spark/pull/39564#issuecomment-1382640160
cc @cloud-fan @sunchao @LuciferYang @panbingkun
--
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 diff in pull request #39564: [SPARK-41990][SQL] Filrering by composite field name doesn't work
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070226875
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/sources/filters.scala:
##########
@@ -91,7 +91,7 @@ case class EqualTo(attribute: String, value: Any) extends Filter {
override def toV2: Predicate = {
val literal = Literal(value)
new Predicate("=",
- Array(FieldReference(attribute), LiteralValue(literal.value, literal.dataType)))
+ Array(FieldReference.column(attribute), LiteralValue(literal.value, literal.dataType)))
Review Comment:
We can add a `protected def toV2Column` in the base class of v1 filter
--
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] huaxingao commented on pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
huaxingao commented on PR #39564:
URL: https://github.com/apache/spark/pull/39564#issuecomment-1383078660
Thanks @dongjoon-hyun @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] huaxingao commented on a diff in pull request #39564: [SPARK-41990][SQL] Filrering by composite field name doesn't work
Posted by GitBox <gi...@apache.org>.
huaxingao commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070233888
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/sources/filters.scala:
##########
@@ -91,7 +91,7 @@ case class EqualTo(attribute: String, value: Any) extends Filter {
override def toV2: Predicate = {
val literal = Literal(value)
new Predicate("=",
- Array(FieldReference(attribute), LiteralValue(literal.value, literal.dataType)))
+ Array(FieldReference.column(attribute), LiteralValue(literal.value, literal.dataType)))
Review Comment:
Thanks for the suggestion! Fixed.
--
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 diff in pull request #39564: [SPARK-41990][SQL] Filrering by composite field name doesn't work
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070226778
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/sources/filters.scala:
##########
@@ -91,7 +91,7 @@ case class EqualTo(attribute: String, value: Any) extends Filter {
override def toV2: Predicate = {
val literal = Literal(value)
new Predicate("=",
- Array(FieldReference(attribute), LiteralValue(literal.value, literal.dataType)))
+ Array(FieldReference.column(attribute), LiteralValue(literal.value, literal.dataType)))
Review Comment:
The column name in v1 filter is generated by `PushableColumn`, and we need to match it.
When nested predicate pushdown is enabled, we already quote the column name if the name is not a valid SQL identifier. So `FieldReference.apply` is correct here. However, when it's disabled, the column name is the parsed name and `FieldReference.column` should be used.
I think what we can do is
```
try {
FieldReference(attribute)
} catch {
case _: ParseException => FieldReference.column(attribute)
}
```
--
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] dongjoon-hyun closed pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun closed pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
URL: https://github.com/apache/spark/pull/39564
--
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] huaxingao commented on a diff in pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
huaxingao commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070860837
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/sources/filters.scala:
##########
@@ -74,6 +75,15 @@ sealed abstract class Filter {
* Converts V1 filter to V2 filter
*/
private[sql] def toV2: Predicate
+
+ protected def toV2Column(attribute: String): NamedReference = {
+ try {
+ FieldReference(attribute)
Review Comment:
I will have a follow up to add some comments.
--
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] dongjoon-hyun commented on pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #39564:
URL: https://github.com/apache/spark/pull/39564#issuecomment-1383072302
Merged to master for Apache Spark 3.4.0. Thank you, @huaxingao and @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 diff in pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070788882
##########
sql/core/src/test/scala/org/apache/spark/sql/jdbc/JDBCSuite.scala:
##########
@@ -1963,4 +1977,9 @@ class JDBCSuite extends QueryTest with SharedSparkSession {
}
}
}
+
+ test("SPARK-41990: Filter with composite name") {
+ val df = sql("SELECT * FROM composite_name WHERE `last name` = 'smith'")
Review Comment:
is it because we always disable nested predicate pushdown for JDBC v1?
--
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 diff in pull request #39564: [SPARK-41990][SQL] Use `FieldReference.column` instead of `apply` in V1 to V2 filter conversion
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #39564:
URL: https://github.com/apache/spark/pull/39564#discussion_r1070788648
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/sources/filters.scala:
##########
@@ -74,6 +75,15 @@ sealed abstract class Filter {
* Converts V1 filter to V2 filter
*/
private[sql] def toV2: Predicate
+
+ protected def toV2Column(attribute: String): NamedReference = {
+ try {
+ FieldReference(attribute)
Review Comment:
We should add some comments to explain it.
--
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