Browse Source

HUE-8307 [pig] Unable to use piggybank installed with Pig examples (#691)

* HUE-8307 [pig] Unable to use piggybank installed with Pig examples

* HUE-8307 [pig] Update statement in pig_setup.py

* HUE-8307 [pig] Use REMOTE_SAMPLE_DIR in example
Ivan Dzikovsky 7 years ago
parent
commit
6bb77875e8

+ 2 - 2
apps/pig/src/pig/conf.py

@@ -27,9 +27,9 @@ from pig.settings import NICE_NAME
 
 
 LOCAL_SAMPLE_DIR = Config(
-  key="local_data_dir",
+  key="local_sample_dir",
   default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"),
-  help=_t("Location on local filesystem where the examples are stored."),
+  help=_t("Path to directory with piggybank.jar on local filesystem."),
   private=True)
 
 REMOTE_SAMPLE_DIR = Config(

+ 2 - 2
apps/pig/src/pig/fixtures/initial_pig_examples.json

@@ -11,7 +11,7 @@
     "pk": 1100713,
     "model": "pig.pigscript",
     "fields": {
-      "data": "{\"job_id\": null, \"parameters\": [], \"script\": \"data = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (text:CHARARRAY);\\n\\n\\nupper_case = FOREACH data GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(text);\\n\\n\\nSTORE upper_case INTO '$output' ;\\n\", \"properties\": [], \"hadoopProperties\": [], \"resources\": [], \"name\": \"UpperText (example)\"}"
+      "data": "{\"job_id\": null, \"parameters\": [], \"script\": \"REGISTER hdfs:///user/hue/pig/examples/piggybank.jar;\\n\\ndata = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (text:CHARARRAY);\\n\\n\\nupper_case = FOREACH data GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(text);\\n\\n\\nSTORE upper_case INTO '$output' ;\\n\", \"properties\": [], \"hadoopProperties\": [], \"resources\": [], \"name\": \"UpperText (example)\"}"
     }
   }
-]
+]

+ 4 - 2
apps/pig/src/pig/management/commands/pig_setup.py

@@ -49,12 +49,14 @@ class Command(BaseCommand):
       LOG.info("Sample pig editor script already installed.")
       doc2 = Document2.objects.get(owner=sample_user, name=name, type='query-pig', is_history=False)
     else:
-      statement = """data = LOAD '/user/hue/pig/examples/data/midsummer.txt' as (text:CHARARRAY);
+      statement = """REGISTER hdfs://{}/piggybank.jar;
+
+data = LOAD '{}/data/midsummer.txt' as (text:CHARARRAY);
 
 upper_case = FOREACH data GENERATE org.apache.pig.piggybank.evaluation.string.UPPER(text);
 
 STORE upper_case INTO '$output';
-"""
+""".format(REMOTE_SAMPLE_DIR.get(), REMOTE_SAMPLE_DIR.get())
       snippet_properties = {
         'hadoopProperties': [],
         'parameters': [],

+ 1 - 1
desktop/conf.dist/hue.ini

@@ -1206,7 +1206,7 @@
 ###########################################################################
 
 [pig]
-  # Location of piggybank.jar on local filesystem.
+  # Path to directory with piggybank.jar on local filesystem.
   ## local_sample_dir=/usr/share/hue/apps/pig/examples
 
   # Location piggybank.jar will be copied to in HDFS.

+ 1 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1208,7 +1208,7 @@
 ###########################################################################
 
 [pig]
-  # Location of piggybank.jar on local filesystem.
+  # Path to directory with piggybank.jar on local filesystem.
   ## local_sample_dir=/usr/share/hue/apps/pig/examples
 
   # Location piggybank.jar will be copied to in HDFS.