返回介绍

Pig Explain 运算符

发布于 2024-06-23 16:54:49 字数 12783 浏览 0 评论 0 收藏 0

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 );

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

  1. grunt> explain student;

它将产生以下输出。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文