Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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 @@ -842,7 +842,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -860,7 +860,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -878,7 +878,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -896,7 +896,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand Down Expand Up @@ -1140,7 +1140,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand All @@ -1158,7 +1158,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand Down Expand Up @@ -1208,7 +1208,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand All @@ -1226,7 +1226,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -796,7 +796,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -814,7 +814,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand All @@ -832,7 +832,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`encode`",
"parameter" : "`charset`"
}
Expand Down Expand Up @@ -1076,7 +1076,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand All @@ -1094,7 +1094,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "Windows-xxx",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand Down Expand Up @@ -1144,7 +1144,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand All @@ -1162,7 +1162,7 @@ org.apache.spark.SparkIllegalArgumentException
"sqlState" : "22023",
"messageParameters" : {
"charset" : "WINDOWS-1252",
"charsets" : "utf-8, utf-16be, iso-8859-1, utf-16le, utf-16, utf-32, us-ascii",
"charsets" : "iso-8859-1, us-ascii, utf-16, utf-16be, utf-16le, utf-32, utf-8",
"functionName" : "`decode`",
"parameter" : "`charset`"
}
Expand Down