You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zzzzming95 (via GitHub)" <gi...@apache.org> on 2023/05/29 14:08:21 UTC

[GitHub] [spark] zzzzming95 opened a new pull request, #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

zzzzming95 opened a new pull request, #41370:
URL: https://github.com/apache/spark/pull/41370

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   Typically, hive partition fields are created as string types.
   
   ```
   CREATE TABLE if not exists test_tb (
   id int
   )
   PARTITIONED BY (dt string)
   ```
   However, cast data conversions are often introduced inadvertently during use. For example
   
   ```
   select * from test_tb where dt=20230505;
   ```
   it will prevent the condition `dt=20230505` from being pushed down into the metastore , because `20230505` is an IntegralType. And resulting in a request for all partitions from metastore.  This can affect execution performance in cases where the data table has very many partitions.
   
   So, in the case of equivalent predicates, partition field pushdown should be supported.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   As described above
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   Manual testing


-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1209357206


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Sorry. It seems incorrect. For example:
   ```sql
   insert into test_tb partition(dt = '20230505.0') select 1;
   ```
   After this PR, the  result of `dt = 20230505` if false?



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1214363841


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   yes.



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1214132294


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Could you add a test to verify 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


[GitHub] [spark] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1225240206


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Yes, at first I thought this could be fixed, but it seems not.Thank you for your 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.

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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1214090326


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Wrapping double quotes should solve this problem.



-- 
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 #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1217481906


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -994,6 +994,18 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
       }
     }
 
+    object ExtractStringAttribute {
+      @scala.annotation.tailrec
+      def unapply(expr: Expression): Option[Attribute] = {
+        expr match {
+          case attr: Attribute => Some(attr)
+          case Cast(child, dt: IntegralType, _, _)
+            if child.dataType.isInstanceOf[StringType] => unapply(child)

Review Comment:
   This assumes Spark and Hive have the same behavior for implicit cast. Is it always true? For example, cast string to int may fail in Spark with ansi mode on, does hive have the same behavior?



-- 
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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1224446791


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   It seems that this issue changes the default behavior.
   
   ```
   CREATE TABLE if not exists t1 ( id int ) PARTITIONED BY (dt string);
   insert into t1 partition(dt = '20230505.0') select 1;
   insert into t1 partition(dt = '20230505') select 2;
   ```
   
   before this issue , the result of `SELECT id FROM t1 WHERE dt = 20230505` 
   ```
   +---+
   | id|
   +---+
   |  2|
   |  1|
   +---+
   ```
   
   After this issue, we can't get it to keep its original behavior.
   
   
   



-- 
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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1218744754


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -994,6 +994,18 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
       }
     }
 
+    object ExtractStringAttribute {
+      @scala.annotation.tailrec
+      def unapply(expr: Expression): Option[Attribute] = {
+        expr match {
+          case attr: Attribute => Some(attr)
+          case Cast(child, dt: IntegralType, _, _)
+            if child.dataType.isInstanceOf[StringType] => unapply(child)

Review Comment:
   No, hive don't allow all `Cast` case to push down to mysql .I submitted a similar patch to hive but did not continue to follow up.
   
   https://github.com/apache/hive/pull/2947
   
   But I think this is feasible in Spark.



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1209357206


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Sorry. It seems incorrect. For example:
   ```sql
   insert into test_tb partition(dt = '20230505.0') select 1;
   ```
   After this PR, the  result of `dt = 20230505` is false?



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1209357206


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Could we enhance `UnwrapCastInBinaryComparison`?



-- 
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] zzzzming95 commented on pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on PR #41370:
URL: https://github.com/apache/spark/pull/41370#issuecomment-1567189353

   @dongjoon-hyun @cloud-fan @HyukjinKwon @wangyum 
   
   Can you take a look in this issue . thanks ~


-- 
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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1216785699


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   This problem seems to occur only when a database such as mysql is used as a metastore database. spark's unit test seems to use derby (in `PruneHiveTablePartitionsSuite` can not occur this case), which cannot reproduce this problem. So it is difficult to implement end-to-end unit test on spark side.



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1224470060


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   This is incorrect, I told you before. I recommend that you change the type of partition column to int/date type.



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1214299609


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   Please add a end to end 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.

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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1224451560


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   > It seems that this issue changes the default behavior.
   > 
   > ```
   > CREATE TABLE if not exists t1 ( id int ) PARTITIONED BY (dt string);
   > insert into t1 partition(dt = '20230505.0') select 1;
   > insert into t1 partition(dt = '20230505') select 2;
   > ```
   > 
   > before this issue , the result of `SELECT * FROM t1 WHERE dt = 20230505`
   > 
   > ```
   > +---+----------+
   > | id|        dt|
   > +---+----------+
   > |  2|  20230505|
   > |  1|20230505.0|
   > +---+----------+
   > ```
   > 
   > After this issue, we can't get it to keep its original behavior.
   
   
   Is this impact acceptable? This issue only affects int to string conversions, and I think dt=20230505 should be equivalent to dt='20230505' when dt is string type. 
   
   @wangyum @cloud-fan  Can you let me know your views. thanks~



-- 
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] wangyum commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1217318011


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   A test like this:
   ```scala
     test("SPARK-43866:xxx") {
       withTable("test_tb") {
         sql("CREATE TABLE test_tb (id int) PARTITIONED BY (dt string)")
         sql("insert into test_tb partition(dt = '20230505.0') select 1")
         val df = sql("select * from test_tb where dt=20230505")
         checkAnswer(df, Row(1, "20230505.0"))
       }
     }
   ```



-- 
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] zzzzming95 closed pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 closed pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate
URL: https://github.com/apache/spark/pull/41370


-- 
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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1224446791


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   It seems that this issue changes the default behavior.
   
   ```
   CREATE TABLE if not exists t1 ( id int ) PARTITIONED BY (dt string);
   insert into t1 partition(dt = '20230505.0') select 1;
   insert into t1 partition(dt = '20230505') select 2;
   ```
   
   before this issue , the result of `SELECT * FROM t1 WHERE dt = 20230505` 
   ```
   +---+----------+
   | id|        dt|
   +---+----------+
   |  2|  20230505|
   |  1|20230505.0|
   +---+----------+
   ```
   
   After this issue, we can't get it to keep its original behavior.
   
   
   



-- 
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] zzzzming95 commented on a diff in pull request #41370: [SPARK-43866] Partition filter condition should pushed down to metastore query if it is equivalence Predicate

Posted by "zzzzming95 (via GitHub)" <gi...@apache.org>.
zzzzming95 commented on code in PR #41370:
URL: https://github.com/apache/spark/pull/41370#discussion_r1214308094


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala:
##########
@@ -1041,6 +1053,9 @@ private[client] class Shim_v0_13 extends Shim_v0_12 {
           ExtractableLiteral(value), ExtractAttribute(SupportedAttribute(name))) =>
         Some(s"$value ${op.symbol} $name")
 
+      case EqualTo(ExtractStringAttribute(SupportedAttribute(name)), ExtractableLiteral(value)) =>
+        Some(s"$name = $value")
+

Review Comment:
   test the case like this ?
   
   ```
   insert into test_tb partition(dt = '20230505.0') select 1;
   select * from dt = 20230505;
   ```



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