课程表

Apache Pig 基础

Apache Pig 诊断运算符

Apache Pig 分组和连接

Apache Pig 合并和拆分

Apache Pig 过滤

Apache Pig 排序

Pig Latin 内置函数

Apache Pig 其他执行模式

工具箱
速查手册

Explain运算符

当前位置:免费教程 » 大数据/云 » Apache Pig

explain 运算符用于显示关系的逻辑,物理和MapReduce执行计划。

语法

下面给出了 explain 运算符的语法。

  1. grunt> explain Relation_name;

假设在HDFS中有一个包含以下内容的文件 student_data.txt

  1. 001,Rajiv,Reddy,9848022337,Hyderabad
  2. 002,siddarth,Battacharya,9848022338,Kolkata
  3. 003,Rajesh,Khanna,9848022339,Delhi
  4. 004,Preethi,Agarwal,9848022330,Pune
  5. 005,Trupthi,Mohanthy,9848022336,Bhuwaneshwar
  6. 006,Archana,Mishra,9848022335,Chennai.

使用LOAD运算符将它读入关系 student ,如下所示。

  1. grunt> student = LOAD 'hdfs://localhost:9000/pig_data/student_data.txt' USING PigStorage(',')
  2. as ( id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray );

现在,让我们使用 explain 运算符解释名为student的关系,如下所示。

  1. grunt> explain student;

输出

它将产生以下输出。

  1. $ explain student;
  2.  
  3. 2015-10-05 11:32:43,660 [main]
  4. 2015-10-05 11:32:43,660 [main] INFO org.apache.pig.newplan.logical.optimizer
  5. .LogicalPlanOptimizer -
  6. {RULES_ENABLED=[AddForEach, ColumnMapKeyPrune, ConstantCalculator,
  7. GroupByConstParallelSetter, LimitOptimizer, LoadTypeCastInserter, MergeFilter,
  8. MergeForEach, PartitionFilterOptimizer, PredicatePushdownOptimizer,
  9. PushDownForEachFlatten, PushUpFilter, SplitFilter, StreamTypeCastInserter]}
  10. #-----------------------------------------------
  11. # New Logical Plan:
  12. #-----------------------------------------------
  13. student: (Name: LOStore Schema:
  14. id#31:int,firstname#32:chararray,lastname#33:chararray,phone#34:chararray,city#
  15. 35:chararray)
  16. |
  17. |---student: (Name: LOForEach Schema:
  18. id#31:int,firstname#32:chararray,lastname#33:chararray,phone#34:chararray,city#
  19. 35:chararray)
  20. | |
  21. | (Name: LOGenerate[false,false,false,false,false] Schema:
  22. id#31:int,firstname#32:chararray,lastname#33:chararray,phone#34:chararray,city#
  23. 35:chararray)ColumnPrune:InputUids=[34, 35, 32, 33,
  24. 31]ColumnPrune:OutputUids=[34, 35, 32, 33, 31]
  25. | | |
  26. | | (Name: Cast Type: int Uid: 31)
  27. | | | | | |---id:(Name: Project Type: bytearray Uid: 31 Input: 0 Column: (*))
  28. | | |
  29. | | (Name: Cast Type: chararray Uid: 32)
  30. | | |
  31. | | |---firstname:(Name: Project Type: bytearray Uid: 32 Input: 1
  32. Column: (*))
  33. | | |
  34. | | (Name: Cast Type: chararray Uid: 33)
  35. | | |
  36. | | |---lastname:(Name: Project Type: bytearray Uid: 33 Input: 2
  37. Column: (*))
  38. | | |
  39. | | (Name: Cast Type: chararray Uid: 34)
  40. | | |
  41. | | |---phone:(Name: Project Type: bytearray Uid: 34 Input: 3 Column:
  42. (*))
  43. | | |
  44. | | (Name: Cast Type: chararray Uid: 35)
  45. | | |
  46. | | |---city:(Name: Project Type: bytearray Uid: 35 Input: 4 Column:
  47. (*))
  48. | |
  49. | |---(Name: LOInnerLoad[0] Schema: id#31:bytearray)
  50. | |
  51. | |---(Name: LOInnerLoad[1] Schema: firstname#32:bytearray)
  52. | |
  53. | |---(Name: LOInnerLoad[2] Schema: lastname#33:bytearray)
  54. | |
  55. | |---(Name: LOInnerLoad[3] Schema: phone#34:bytearray)
  56. | |
  57. | |---(Name: LOInnerLoad[4] Schema: city#35:bytearray)
  58. |
  59. |---student: (Name: LOLoad Schema:
  60. id#31:bytearray,firstname#32:bytearray,lastname#33:bytearray,phone#34:bytearray
  61. ,city#35:bytearray)RequiredFields:null
  62. #-----------------------------------------------
  63. # Physical Plan: #-----------------------------------------------
  64. student: Store(fakefile:org.apache.pig.builtin.PigStorage) - scope-36
  65. |
  66. |---student: New For Each(false,false,false,false,false)[bag] - scope-35
  67. | |
  68. | Cast[int] - scope-21
  69. | |
  70. | |---Project[bytearray][0] - scope-20
  71. | |
  72. | Cast[chararray] - scope-24
  73. | |
  74. | |---Project[bytearray][1] - scope-23
  75. | |
  76. | Cast[chararray] - scope-27
  77. | |
  78. | |---Project[bytearray][2] - scope-26
  79. | |
  80. | Cast[chararray] - scope-30
  81. | |
  82. | |---Project[bytearray][3] - scope-29
  83. | |
  84. | Cast[chararray] - scope-33
  85. | |
  86. | |---Project[bytearray][4] - scope-32
  87. |
  88. |---student: Load(hdfs://localhost:9000/pig_data/student_data.txt:PigStorage(',')) - scope19
  89. 2015-10-05 11:32:43,682 [main]
  90. INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MRCompiler -
  91. File concatenation threshold: 100 optimistic? false
  92. 2015-10-05 11:32:43,684 [main]
  93. INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MultiQueryOp timizer -
  94. MR plan size before optimization: 1 2015-10-05 11:32:43,685 [main]
  95. INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.
  96. MultiQueryOp timizer - MR plan size after optimization: 1
  97. #--------------------------------------------------
  98. # Map Reduce Plan
  99. #--------------------------------------------------
  100. MapReduce node scope-37
  101. Map Plan
  102. student: Store(fakefile:org.apache.pig.builtin.PigStorage) - scope-36
  103. |
  104. |---student: New For Each(false,false,false,false,false)[bag] - scope-35
  105. | |
  106. | Cast[int] - scope-21
  107. | |
  108. | |---Project[bytearray][0] - scope-20
  109. | |
  110. | Cast[chararray] - scope-24
  111. | |
  112. | |---Project[bytearray][1] - scope-23
  113. | |
  114. | Cast[chararray] - scope-27
  115. | |
  116. | |---Project[bytearray][2] - scope-26
  117. | |
  118. | Cast[chararray] - scope-30
  119. | |
  120. | |---Project[bytearray][3] - scope-29
  121. | |
  122. | Cast[chararray] - scope-33
  123. | |
  124. | |---Project[bytearray][4] - scope-32
  125. |
  126. |---student:
  127. Load(hdfs://localhost:9000/pig_data/student_data.txt:PigStorage(',')) - scope
  128. 19-------- Global sort: false
  129. ----------------
转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号