Advertisement
MARSHAL327

bdot command

Oct 10th, 2023 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. sqoop import-all-tables \
  2. -m 1 \
  3. --connect jdbc:mysql://quickstart:3306/retail_db \
  4. --username=retail_dba \
  5. --password=cloudera \
  6. --as-avrodatafile \
  7. --warehouse-dir=/user/hive/warehouse
  8.  
  9.  
  10.  
  11. hadoop fs -ls /user/hive/warehouse
  12.  
  13.  
  14.  
  15. hadoop fs -ls /user/hive/warehouse/categories
  16.  
  17.  
  18.  
  19. sudo -u hdfs hadoop fs -mkdir /user/examples
  20. sudo -u hdfs hadoop fs -chmod +rw /user/examples
  21. hadoop fs -copyFromLocal ~/*.avsc /user/examples
  22.  
  23.  
  24.  
  25. CREATE EXTERNAL TABLE categories STORED AS AVRO
  26. LOCATION 'hdfs:///user/hive/warehouse/categories'
  27. TBLPROPERTIES
  28. ('avro.schema.url'='hdfs://quickstart/user/examples/categories.avsc');
  29. CREATE EXTERNAL TABLE customers STORED AS AVRO
  30. LOCATION 'hdfs:///user/hive/warehouse/customers'
  31. TBLPROPERTIES
  32. ('avro.schema.url'='hdfs://quickstart/user/examples/customers.avsc');
  33. CREATE EXTERNAL TABLE departments STORED AS AVRO
  34. LOCATION 'hdfs:///user/hive/warehouse/departments'
  35. TBLPROPERTIES
  36. ('avro.schema.url'='hdfs://quickstart/user/examples/departments.avsc');
  37. CREATE EXTERNAL TABLE orders STORED AS AVRO
  38. LOCATION 'hdfs:///user/hive/warehouse/orders'
  39. TBLPROPERTIES
  40. ('avro.schema.url'='hdfs://quickstart/user/examples/orders.avsc');
  41. CREATE EXTERNAL TABLE order_items STORED AS AVRO
  42. LOCATION 'hdfs:///user/hive/warehouse/order_items'
  43. TBLPROPERTIES
  44. ('avro.schema.url'='hdfs://quickstart/user/examples/order_items.avsc');
  45. CREATE EXTERNAL TABLE products STORED AS AVRO
  46. LOCATION 'hdfs:///user/hive/warehouse/products'
  47. TBLPROPERTIES
  48. ('avro.schema.url'='hdfs://quickstart/user/examples/products.avsc');
  49.  
  50.  
  51.  
  52. -- Most popular product categories
  53. select c.category_name, count(order_item_quantity) as count
  54. from order_items oi
  55. inner join products p on oi.order_item_product_id = p.product_id
  56. inner join categories c on c.category_id = p.product_category_id
  57. group by c.category_name
  58. order by count desc
  59. limit 10;
  60.  
  61.  
  62.  
  63. (по варианту)
  64. -- Products that costs less 100 dollars
  65. select product_name as product, product_price as price
  66. from products
  67. where product_price < 100
  68. order by product_price desc;
  69.  
  70.  
  71.  
  72. hdfs dfs -put /etc/passwd /user/cloudera
  73. pig -x mapreduce
  74.  
  75. A = load '/user/cloudera/passwd' using PigStorage(':');
  76. B = foreach A generate $0, $4, $5 ;
  77. dump B;
  78.  
  79. store B into 'userinfo.out';
  80. hadoop fs -ls /user/hive/warehouse
  81.  
  82.  
  83.  
  84. hdfs dfs -put /etc/passwd /tmp/
  85.  
  86. beeline -u jdbc:hive2://
  87.  
  88. CREATE TABLE userinfo ( uname STRING, pswd STRING, uid INT, gid
  89. INT, fullname STRING, hdir STRING, shell STRING ) ROW FORMAT
  90. DELIMITED FIELDS TERMINATED BY ':' STORED AS TEXTFILE;
  91.  
  92. LOAD DATA INPATH '/tmp/passwd' OVERWRITE INTO TABLE userinfo;
  93. SELECT uname, fullname, hdir FROM userinfo ORDER BY uname;
  94.  
  95.  
  96.  
  97.  
  98. hbase shell
  99.  
  100. create 'usertableinfo',{NAME=>'username'},{NAME=>'fullname'},{NAME=>'hom edir'}
  101.  
  102. put 'usertableinfo', 'r1', 'username', 'vcsa'
  103. put 'usertableinfo', 'r2', 'username', 'sasuser'
  104. put 'usertableinfo', 'r3', 'username', 'postfix'
  105. put 'usertableinfo', 'r1', 'fullname', 'Virtual Machine Admin'
  106. put 'usertableinfo', 'r2', 'fullname', 'SAS Admin'
  107. put 'usertableinfo', 'r3', 'fullname', 'Postfix User'
  108.  
  109. scan 'usertableinfo', { FILTER => "KeyOnlyFilter()"}
  110. scan 'usertableinfo', { FILTER => "FirstKeyOnlyFilter()"}
  111.  
  112.  
  113.  
  114.  
  115. (по варианту)
  116. create 'customers',{NAME=>'customer_name'},{NAME=>'customer_sex'},{NAME=>'customer_age'}
  117.  
  118. put 'customers', 'r1', 'customer_name', 'Ivan'
  119. put 'customers', 'r2', 'customer_name', 'Darya'
  120. put 'customers', 'r3', 'customer_name', 'Kirill'
  121. put 'customers', 'r1', 'customer_sex', 'M'
  122. put 'customers', 'r2', 'customer_sex', 'F'
  123. put 'customers', 'r3', 'customer_sex', 'M'
  124. put 'customers', 'r1', 'customer_age', '23'
  125. put 'customers', 'r2', 'customer_age', '20'
  126. put 'customers', 'r3', 'customer_age', '18'
  127.  
  128. scan 'customers', { FILTER => "KeyOnlyFilter()"}
  129.  
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement