Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-49775][SQL][TESTS] Make tests of INVALID_PARAMETER_VALUE.CHARSET deterministic #48235

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
private[sql] object CharsetProvider {

final lazy val VALID_CHARSETS =
Set("us-ascii", "iso-8859-1", "utf-8", "utf-16be", "utf-16le", "utf-16", "utf-32")
Array("us-ascii", "iso-8859-1", "utf-8", "utf-16be", "utf-16le", "utf-16", "utf-32").sorted
Copy link
Member

Choose a reason for hiding this comment

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

Is it more performant to use the contains of set than array?

Copy link
Member

Choose a reason for hiding this comment

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

It's happening once anyway so shouldn't be a biggie. invalidCharsetError happens for every call

Copy link
Member

Choose a reason for hiding this comment

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

charset can be a column value,this could be expensive?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, in that case, we should probably keep this as a set, and just create another variable sorted.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Great idea!

Copy link
Member

Choose a reason for hiding this comment

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

Here: #48245

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good!


def forName(
charset: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
"functionName" -> toSQLId(functionName),
"parameter" -> toSQLId("charset"),
"charset" -> charset,
"charsets" -> CharsetProvider.VALID_CHARSETS.toSeq.sorted.mkString(", ")))
"charsets" -> CharsetProvider.VALID_CHARSETS.mkString(", ")))
}

def malformedCharacterCoding(functionName: String, charset: String): RuntimeException = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ abstract class CSVSuite
"charset" -> "1-9588-osi",
"functionName" -> toSQLId("CSVOptions"),
"parameter" -> toSQLId("charset"),
"charsets" -> CharsetProvider.VALID_CHARSETS.toSeq.sorted.mkString(", "))
"charsets" -> CharsetProvider.VALID_CHARSETS.mkString(", "))
)
}

Expand Down Expand Up @@ -655,7 +655,7 @@ abstract class CSVSuite
"charset" -> "1-9588-osi",
"functionName" -> toSQLId("CSVOptions"),
"parameter" -> toSQLId("charset"),
"charsets" -> CharsetProvider.VALID_CHARSETS.toSeq.sorted.mkString(", "))
"charsets" -> CharsetProvider.VALID_CHARSETS.mkString(", "))
)
}

Expand Down