如何在将数据插入 table 的 Hive 时转义 html 代码数据
How to escape html code data while inserting data into a table of Hive
我需要将数据插入到我的 table 列之一,该列具有特殊字符,例如 < > - .....
所以我给了 \ 用作每个文字的转义字符
这是我要插入的列 "Introduction" 的数据。
数据来自 csv 文件,所有数据都用双引号括起来
"<p><span style=""font-family: \'Calibri Light\': sans-serif\; font-size: xx-large\; color: #2184c2\;""><span style=""font-size: 28pt\;""><span style=""font-size: x-large\;""><span style=""font-size: 18pt\;""><strong>Help us improve by taking our short satisfaction survey. \;</strong></span></span></span></span></p>"
当我尝试插入此数据时,出现以下错误。
AnalysisException: Syntax error in line 1:\n...","","<p><span style="font-family: \\\'Calibri Light\\\'...\n ^\nEncountered: -\nExpected: CROSS, FROM, FULL, GROUP, HAVING, INNER, JOIN, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, STRAIGHT_JOIN, TABLESAMPLE, UNION, USING, WHERE, COMMA\n\nCAUSED BY: Exception: Syntax error\n (110) (SQLExecDirectW)')
日志类型 - 信息日志
谁能帮我把这种数据插入到 table
分号和单引号需要使用反斜杠转义:
create table test_str as select '<p><span style=""font-family: \'Calibri Light\', sans-serif\; font-size: xx-large\; color: #2184c2\;""><span style=""font-size: 28pt\;""><span style=""font-size: x-large\;""><span style=""font-size: 18pt\;""><strong>Help us improve by taking our short satisfaction survey \;</strong></span></span></span></span></p>';
select * from test_str;
结果:
<p><span style=""font-family: 'Calibri Light', sans-serif; font-size: xx-large; color: #2184c2;""><span style=""font-size: 28pt;""><span style=""font-size: x-large;""><span style=""font-size: 18pt;""><strong>Help us improve by taking our short satisfaction survey </strong></span></span></span></span></p>
我需要将数据插入到我的 table 列之一,该列具有特殊字符,例如 < > - ..... 所以我给了 \ 用作每个文字的转义字符
这是我要插入的列 "Introduction" 的数据。 数据来自 csv 文件,所有数据都用双引号括起来
"<p><span style=""font-family: \'Calibri Light\': sans-serif\; font-size: xx-large\; color: #2184c2\;""><span style=""font-size: 28pt\;""><span style=""font-size: x-large\;""><span style=""font-size: 18pt\;""><strong>Help us improve by taking our short satisfaction survey. \;</strong></span></span></span></span></p>"
当我尝试插入此数据时,出现以下错误。
AnalysisException: Syntax error in line 1:\n...","","<p><span style="font-family: \\\'Calibri Light\\\'...\n ^\nEncountered: -\nExpected: CROSS, FROM, FULL, GROUP, HAVING, INNER, JOIN, LEFT, LIMIT, OFFSET, ON, ORDER, RIGHT, STRAIGHT_JOIN, TABLESAMPLE, UNION, USING, WHERE, COMMA\n\nCAUSED BY: Exception: Syntax error\n (110) (SQLExecDirectW)')
日志类型 - 信息日志
谁能帮我把这种数据插入到 table
分号和单引号需要使用反斜杠转义:
create table test_str as select '<p><span style=""font-family: \'Calibri Light\', sans-serif\; font-size: xx-large\; color: #2184c2\;""><span style=""font-size: 28pt\;""><span style=""font-size: x-large\;""><span style=""font-size: 18pt\;""><strong>Help us improve by taking our short satisfaction survey \;</strong></span></span></span></span></p>';
select * from test_str;
结果:
<p><span style=""font-family: 'Calibri Light', sans-serif; font-size: xx-large; color: #2184c2;""><span style=""font-size: 28pt;""><span style=""font-size: x-large;""><span style=""font-size: 18pt;""><strong>Help us improve by taking our short satisfaction survey </strong></span></span></span></span></p>