【发布时间】:2014-09-21 06:38:49
【问题描述】:
当我尝试将 csv 导入我的 Redshift 数据库时,我收到此错误
Missing newline: Unexpected character 0x75 found at location 4194303
csv 本身似乎一切正常。 stl 表告诉我错误在 csv 的第 70269 行,其中包含此字符串
10:00:10,2014-07-28,Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0),Not Listed,Not Listed,Not Listed,Not Listed,multiRetrieve,Not Listed,OS-Preview-logItemUsage,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,"[{""PubEndDate""=>""2013/12/31"", ""ItmId""=>""1353296053"", ""SourceType""=>""Scholarly Journals"", ""ReasonCode""=>""Free"", ""MyResearchUser""=>""246763"", ""ProjectCode""=>"""", ""PublicationCode""=>"""", ""PubStartDate""=>""2013/01/01"", ""ItmFrmt""=>""AbstractPreview"", ""Subrole""=>""AbstractPreview"", ""PaymentType""=>""Transactional"", ""UsageInfo""=>""P-1008275-154977-CUSTOMER-10000137-2950635"", ""Role""=>""AbstractPreview"", ""RetailPrice""=>0, ""EffectivePrice""=>0, ""ParentItemId""=>""53628""}]","[""optype:Online"", ""location:null"", ""target:null""]",192.234.111.8,DIALOG,20140728131712007:882391,1119643,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,Not Listed,"2014-07-28 10:00:10-0400,421 {""Items"":[{""PubEndDate"":""2013/12/31"",""ItmId"":""1353296053"",""SourceType"":""Scholarly Journals"",""ReasonCode"":""Free"",""MyResearchUser"":""246763"",""ProjectCode"":"""",""PublicationCode"":"""",""PubStartDate"":""2013/01/01"",""ItmFrmt"":""AbstractPreview"",""Subrole"":""AbstractPreview"",""PaymentType"":""Transactional"",""UsageInfo"":""P-1008275-154977-CUSTOMER-10000137-2950635"",""Role"":""AbstractPreview"",""RetailPrice"":0,""EffectivePrice"":0,""ParentItemId"":""53628""}],""Operation"":[""optype:Online"",""location:null"",""target:null""],""UserAgent"":""Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"",""UserInfo"":{""IP"":""192.234.111.8"",""AppId"":""DIALOG"",""SessId"":""20140728131712007:882391"",""UsageGroupId"":""1119643""},""UsageType"":""multiRetrieve"",""BreadCrumb"":""OS-Preview-logItemUsage""}
任何想法为什么它不会加载?
编辑:这显然与数字“4194303”有关。我的许多 redshift 上传都失败了,这是我的 stl_load_errors 的简短示例
Missing newline: Unexpected character 0x3a found at location 4194303
Missing newline: Unexpected character 0x63 found at location 4194303
Missing newline: Unexpected character 0x6c found at location 4194303
Missing newline: Unexpected character 0x22 found at location 4194303
表中出现这些错误的所有条目均为“文本”类型,大约有 30 列。 csv 本身包含数千条记录(相当大的 csv 文件)。
解决方法(不是解决方案)
我发现数字 4194303 来自 Redshift 复制的 TRUNCATECOLUMNS 功能设置的 4MB 限制。通过禁用此功能,我会收到“字符串长度超过 DDL 长度”错误(这就是我首先使用 TRUNCATECOLUMNS 的原因)。
所以问题是我的许多记录都超过了 4MB,如果需要截断任何属性,redshift 不支持此类记录。
但是,通过使用复制命令的 MAXERROR 1000 选项,我可以忽略 4MB+ 的记录,并留下一个仅包含我想要的小于 4MB 的行的数据库。
【问题讨论】:
标签: database postgresql csv amazon-redshift