我有一个需要加载到配置单元表的源文件。两个字段是存储时间的数组,无论我如何尝试,都无法将它们作为数组结构加载。
源文件:
1ab345c5f964a520da6z20e3|This Store Name|[{day:1,starttime:330,endtime:1260},{day:2,starttime:330,endtime:1260},{day:3,starttime:330,endtime:1260},{day:4,starttime:330,endtime:1260},{day:5,starttime:330,endtime:1260},{day:6,starttime:330,endtime:1260},{day:7,starttime:330,endtime:1260}]|[{startdate:{month:3,day:27},enddate:{month:3,day:27},weeklyhours:[{day:5,starttime:0,endtime:1440}],closed:true},{startdate:{month:3,day:28},enddate:{month:3,day:28},weeklyhours:[{day:6,starttime:0,endtime:1440}],closed:true},{startdate:{month:3,day:29},enddate:{month:3,day:29},weeklyhours:[{day:7,starttime:0,endtime:1440}],closed:true},{startdate:{month:3,day:30},enddate:{month:3,day:30},weeklyhours:[{day:1,starttime:0,endtime:1440}],closed:true},{startdate:{month:3,day:31},enddate:{month:3,day:31},weeklyhours:[{day:2,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:1},enddate:{month:4,day:1},weeklyhours:[{day:3,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:2},enddate:{month:4,day:2},weeklyhours:[{day:4,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:3},enddate:{month:4,day:3},weeklyhours:[{day:5,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:4},enddate:{month:4,day:4},weeklyhours:[{day:6,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:5},enddate:{month:4,day:5},weeklyhours:[{day:7,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:6},enddate:{month:4,day:6},weeklyhours:[{day:1,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:7},enddate:{month:4,day:7},weeklyhours:[{day:2,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:8},enddate:{month:4,day:8},weeklyhours:[{day:3,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:9},enddate:{month:4,day:9},weeklyhours:[{day:4,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:10},enddate:{month:4,day:10},weeklyhours:[{day:5,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:11},enddate:{month:4,day:11},weeklyhours:[{day:6,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:12},enddate:{month:4,day:12},weeklyhours:[{day:7,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:13},enddate:{month:4,day:13},weeklyhours:[{day:1,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:14},enddate:{month:4,day:14},weeklyhours:[{day:2,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:15},enddate:{month:4,day:15},weeklyhours:[{day:3,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:16},enddate:{month:4,day:16},weeklyhours:[{day:4,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:17},enddate:{month:4,day:17},weeklyhours:[{day:5,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:18},enddate:{month:4,day:18},weeklyhours:[{day:6,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:19},enddate:{month:4,day:19},weeklyhours:[{day:7,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:20},enddate:{month:4,day:20},weeklyhours:[{day:1,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:21},enddate:{month:4,day:21},weeklyhours:[{day:2,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:22},enddate:{month:4,day:22},weeklyhours:[{day:3,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:23},enddate:{month:4,day:23},weeklyhours:[{day:4,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:24},enddate:{month:4,day:24},weeklyhours:[{day:5,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:25},enddate:{month:4,day:25},weeklyhours:[{day:6,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:26},enddate:{month:4,day:26},weeklyhours:[{day:7,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:27},enddate:{month:4,day:27},weeklyhours:[{day:1,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:28},enddate:{month:4,day:28},weeklyhours:[{day:2,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:29},enddate:{month:4,day:29},weeklyhours:[{day:3,starttime:0,endtime:1440}],closed:true},{startdate:{month:4,day:30},enddate:{month:4,day:30},weeklyhours:[{day:4,starttime:0,endtime:1440}],closed:true}]
这是我试过的一件事。
create external table store_hours (venueid string, venuename string,
hours array<struct<day:int,starttime:int,endtime:int>>,
seasonal_hours array<struct<startdate:struct<month:int,day:int,year:int>,enddate:struct<month:int,day:int,year:int>,weeklyhours:array<struct<day:int,starttime:int,endtime:int,label:string>>,closed:boolean>>
)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
COLLECTION ITEMS TERMINATED BY ','
MAP KEYS TERMINATED BY ':'
STORED AS TEXTFILE LOCATION '/path/to/data';
选择*从商店\小时;退货:
1ab345c5f964a520da6z20e3 This Store Name [{"day":null,"starttime":1,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":2,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":3,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":4,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":5,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":6,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null},{"day":null,"starttime":7,"endtime":null},{"day":null,"starttime":330,"endtime":null},{"day":null,"starttime":null,"endtime":null}]
对于“hours”,数据大多为空,但实际上有些数据正在被读取并赋值,但赋值显然是错误的。
“小时”字段数组的第一个值是“[{day:1,starttime:330,endtime:1260},…”看起来好像“day”中的“1”被分配给了“starttime”。然后starttime中的“330”被分配给starttime,但在第二个数组中,不是第一个数组。而且结束时间看起来永远不会被分配到任何地方。
“季节性小时”字段输出类似,其中大多数为空,有些值填充在不同/错误的位置。
我不知道这是如何真正执行和加载,我很明显错过了一些东西。谢谢你的帮助。
暂无答案!
目前还没有任何答案,快来回答吧!