Skip to content

[SPARK-37013][CORE][SQL][FOLLOWUP] Use the new error framework to throw error in FormatString #34454

Closed
LuciferYang wants to merge 3 commits intoapache:masterfrom
LuciferYang:SPARK-37013-FOLLOWUP
Closed

[SPARK-37013][CORE][SQL][FOLLOWUP] Use the new error framework to throw error in FormatString #34454
LuciferYang wants to merge 3 commits intoapache:masterfrom
LuciferYang:SPARK-37013-FOLLOWUP

Conversation

@LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Nov 1, 2021

What changes were proposed in this pull request?

This is a followup of #34313. The main change of this pr is change to use the new error framework to throw error when pattern.contains("%0$") is true.

Why are the changes needed?

Use the new error framework to throw error

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass the Jenkins or GitHub Action

@LuciferYang
Copy link
Contributor Author

let's use the new error framework to throw error in newly added code.

cc @cloud-fan , follow your advice in #34313

@@ -1685,7 +1685,7 @@ case class ParseUrl(children: Seq[Expression], failOnError: Boolean = SQLConf.ge
case class FormatString(children: Expression*) extends Expression with ImplicitCastInputTypes {

require(children.nonEmpty, s"$prettyName() should take at least 1 argument")
Copy link
Contributor Author

@LuciferYang LuciferYang Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan this pr only change the newly added code, If also need to change line 1687, please let me know.

"IF_PARTITION_NOT_EXISTS_UNSUPPORTED" : {
"message" : [ "Cannot write, IF NOT EXISTS is not supported for table: %s" ]
},
"ILLEGAL_FORMAT_ARGUMENT_INDEX" : {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we have a unified error class for illegal format string? cc @karenfeng

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple different ways for a string to have an illegal format, right? I'm not sure how to unify them all, but we can definitely have a more generic class here to represent that a string cannot contain a given substring, eg:

"ILLEGAL_SUBSTRING" : {
   "message" : [ "%s cannot contain %s." ]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karenfeng bf5790d fix this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cloud-fan, does this LGTY? I don't have any more concerns.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuciferYang LuciferYang changed the title [SPARK-37013][SQL][FOLLOWUP] Use the new error framework to throw error in FormatString [SPARK-37013][CORE][SQL][FOLLOWUP] Use the new error framework to throw error in FormatString Nov 1, 2021
@SparkQA
Copy link

SparkQA commented Nov 1, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49273/

@SparkQA
Copy link

SparkQA commented Nov 1, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49273/

@SparkQA
Copy link

SparkQA commented Nov 1, 2021

Test build #144803 has finished for PR 34454 at commit af98949.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roryqi
Copy link
Contributor

roryqi commented Nov 10, 2021

attern.contains("%0$") is true.
typo? 'attern' -> pattern?

@LuciferYang
Copy link
Contributor Author

@jerqi thanks~already update the pr description

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49548/

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49548/

@SparkQA
Copy link

SparkQA commented Nov 11, 2021

Test build #145079 has finished for PR 34454 at commit bf5790d.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@LuciferYang
Copy link
Contributor Author

Anything else needs to be changed?

@LuciferYang
Copy link
Contributor Author

Gentle ping @karenfeng once more

@cloud-fan
Copy link
Contributor

Sorry I missed the ping. Merging to master, thanks!

@cloud-fan cloud-fan closed this in 537b102 Nov 23, 2021
@LuciferYang
Copy link
Contributor Author

thanks all ~

cloud-fan pushed a commit that referenced this pull request Apr 8, 2022
…of forbidding %0$ usage in format_string

### What changes were proposed in this pull request?
Adds a legacy flag `spark.sql.legacy.allowZeroIndexInFormatString` for the breaking change introduced in #34313 and #34454 (followup).

The flag is disabled by default. But when it is enabled, restore the pre-change behavior that allows the 0 based index in `format_string`.

### Why are the changes needed?
The original commit is a breaking change, and breaking changes should be encouraged to add a flag to turn it off for smooth migration between versions.

### Does this PR introduce _any_ user-facing change?
With the default value of the conf, there is no user-facing difference.
If users turn this conf on, they can restore the pre-change behavior.

### How was this patch tested?
Through unit tests.

Closes #36101 from anchovYu/flags-format-string-java.

Authored-by: Xinyi Yu <xinyi.yu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan pushed a commit that referenced this pull request Apr 8, 2022
…of forbidding %0$ usage in format_string

### What changes were proposed in this pull request?
Adds a legacy flag `spark.sql.legacy.allowZeroIndexInFormatString` for the breaking change introduced in #34313 and #34454 (followup).

The flag is disabled by default. But when it is enabled, restore the pre-change behavior that allows the 0 based index in `format_string`.

### Why are the changes needed?
The original commit is a breaking change, and breaking changes should be encouraged to add a flag to turn it off for smooth migration between versions.

### Does this PR introduce _any_ user-facing change?
With the default value of the conf, there is no user-facing difference.
If users turn this conf on, they can restore the pre-change behavior.

### How was this patch tested?
Through unit tests.

Closes #36101 from anchovYu/flags-format-string-java.

Authored-by: Xinyi Yu <xinyi.yu@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit b7af2b3)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
@LuciferYang LuciferYang deleted the SPARK-37013-FOLLOWUP branch October 22, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants