gpt4 book ai didi

hadoop - 错误 1070 : Could not resolve toDate using imports: [, java.lang., > org.apache.pig.builtin., org.apache.pig.impl.builtin.]

转载 作者:可可西里 更新时间:2023-11-01 16:39:52 25 4
gpt4 key购买 nike

使用 pig 将数据转换为日期时间时出现问题。导入以下数据集,制表符分隔,我添加了\t 来说明。

5000001 \t  1133938 \t 1273719 \t 2008-06-01 00:03:35.0

我想获取最后一个值 (2008-06-01 00:03:35.0) 并提取月份。将其加载为 DateTime 会生成一个空白字段。因此,我想将其导入为字符数组,然后使用 toDate 将其转换为我可以在其上使用 getMonth 的日期时间字段。

当我在 shell 中尝试时,我得到了这个:

grunt> orders = load '/home/cloudera/Desktop/orders1' using PigStorage('\t') AS (orderID:int, cusID:int, productId:chararray, time:chararray);
grunt> to_date = FOREACH orders GENERATE toDate(time,'yyyy-MM-dd HH:mm:ss.S') as (dTime:DateTime), cusID;
2017-04-19 01:13:46,206 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1070: Could not resolve toDate using imports: [, java.lang., org.apache.pig.builtin., org.apache.pig.impl.builtin.]
Details at logfile: /home/cloudera/pig_1492588751037.log

日志文件包含以下内容:

ERROR 1070: Could not resolve toDate using imports: [, java.lang.,org.apache.pig.builtin., org.apache.pig.impl.builtin.]

Failed to parse: Pig script failed to parse: <line 9, column 34>Failed to generate logical plan. Nested exception:org.apache.pig.backend.executionengine.ExecException: ERROR 1070:Could not resolve toDate using imports: [, java.lang.,org.apache.pig.builtin., org.apache.pig.impl.builtin.] atorg.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:196)at org.apache.pig.PigServer$Graph.validateQuery(PigServer.java:1660)at org.apache.pig.PigServer$Graph.registerQuery(PigServer.java:1633)at org.apache.pig.PigServer.registerQuery(PigServer.java:587) atorg.apache.pig.tools.grunt.GruntParser.processPig(GruntParser.java:1093)atorg.apache.pig.tools.pigscript.parser.PigScriptParser.parse(PigScriptParser.java:501)atorg.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:198)atorg.apache.pig.tools.grunt.GruntParser.parseStopOnError(GruntParser.java:173)at org.apache.pig.tools.grunt.Grunt.run(Grunt.java:69) atorg.apache.pig.Main.run(Main.java:547) atorg.apache.pig.Main.main(Main.java:158) atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606) atorg.apache.hadoop.util.RunJar.run(RunJar.java:221) atorg.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by: <line9, column 34> Failed to generate logical plan. Nested exception:org.apache.pig.backend.executionengine.ExecException: ERROR 1070:Could not resolve toDate using imports: [, java.lang.,org.apache.pig.builtin., org.apache.pig.impl.builtin.] atorg.apache.pig.parser.LogicalPlanBuilder.buildUDF(LogicalPlanBuilder.java:1507)atorg.apache.pig.parser.LogicalPlanGenerator.func_eval(LogicalPlanGenerator.java:9372)atorg.apache.pig.parser.LogicalPlanGenerator.projectable_expr(LogicalPlanGenerator.java:11051)atorg.apache.pig.parser.LogicalPlanGenerator.var_expr(LogicalPlanGenerator.java:10810)atorg.apache.pig.parser.LogicalPlanGenerator.expr(LogicalPlanGenerator.java:10159)atorg.apache.pig.parser.LogicalPlanGenerator.flatten_generated_item(LogicalPlanGenerator.java:7488)atorg.apache.pig.parser.LogicalPlanGenerator.generate_clause(LogicalPlanGenerator.java:17590)atorg.apache.pig.parser.LogicalPlanGenerator.foreach_plan(LogicalPlanGenerator.java:15982)atorg.apache.pig.parser.LogicalPlanGenerator.foreach_clause(LogicalPlanGenerator.java:15849)atorg.apache.pig.parser.LogicalPlanGenerator.op_clause(LogicalPlanGenerator.java:1933)atorg.apache.pig.parser.LogicalPlanGenerator.general_statement(LogicalPlanGenerator.java:1102)atorg.apache.pig.parser.LogicalPlanGenerator.statement(LogicalPlanGenerator.java:560)atorg.apache.pig.parser.LogicalPlanGenerator.query(LogicalPlanGenerator.java:421)atorg.apache.pig.parser.QueryParserDriver.parse(QueryParserDriver.java:188)... 16 more Caused by:org.apache.pig.backend.executionengine.ExecException: ERROR 1070:Could not resolve toDate using imports: [, java.lang.,org.apache.pig.builtin., org.apache.pig.impl.builtin.] atorg.apache.pig.impl.PigContext.resolveClassName(PigContext.java:653)atorg.apache.pig.impl.PigContext.getClassForAlias(PigContext.java:769)atorg.apache.pig.parser.LogicalPlanBuilder.buildUDF(LogicalPlanBuilder.java:1504)... 29 more

最佳答案

Pig 函数名称区分大小写。它是 ToDate()

grunt> to_date = FOREACH orders GENERATE ToDate(time,'yyyy-MM-dd HH:mm:ss.S') as (dTime:DateTime), cusID;

关于hadoop - 错误 1070 : Could not resolve toDate using imports: [, java.lang., > org.apache.pig.builtin., org.apache.pig.impl.builtin.],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43490287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com