@@ -140,17 +140,10 @@ private[sql] class JSONOptionsInRead(
140
140
}
141
141
142
142
protected override def checkedEncoding (enc : String ): String = {
143
- // The following encodings are not supported in per-line mode (multiline is false)
144
- // because they cause some problems in reading files with BOM which is supposed to
145
- // present in the files with such encodings. After splitting input files by lines,
146
- // only the first lines will have the BOM which leads to impossibility for reading
147
- // the rest lines. Besides of that, the lineSep option must have the BOM in such
148
- // encodings which can never present between lines.
149
- val blacklist = Seq (Charset .forName(" UTF-16" ), Charset .forName(" UTF-32" ))
150
- val isBlacklisted = blacklist.contains(Charset .forName(enc))
143
+ val isBlacklisted = JSONOptionsInRead .blacklist.contains(Charset .forName(enc))
151
144
require(multiLine || ! isBlacklisted,
152
145
s """ The ${enc} encoding must not be included in the blacklist when multiLine is disabled:
153
- |Blacklist: ${blacklist.mkString(" , " )}""" .stripMargin)
146
+ |Blacklist: ${JSONOptionsInRead . blacklist.mkString(" , " )}""" .stripMargin)
154
147
155
148
val isLineSepRequired =
156
149
multiLine || Charset .forName(enc) == StandardCharsets .UTF_8 || lineSeparator.nonEmpty
@@ -159,3 +152,16 @@ private[sql] class JSONOptionsInRead(
159
152
enc
160
153
}
161
154
}
155
+
156
+ private [sql] object JSONOptionsInRead {
157
+ // The following encodings are not supported in per-line mode (multiline is false)
158
+ // because they cause some problems in reading files with BOM which is supposed to
159
+ // present in the files with such encodings. After splitting input files by lines,
160
+ // only the first lines will have the BOM which leads to impossibility for reading
161
+ // the rest lines. Besides of that, the lineSep option must have the BOM in such
162
+ // encodings which can never present between lines.
163
+ val blacklist = Seq (
164
+ Charset .forName(" UTF-16" ),
165
+ Charset .forName(" UTF-32" )
166
+ )
167
+ }
0 commit comments