25178

How to project an alias using a wildcard?

Once I do a join A by id, B by id, I get an alias with fields A::f..., B::f... Is there a way to project it on only the A fields?

C = join A by id, B by id; D = filter C by B::n < 1000; E = foreach D generate A::*;

I get

Unexpected character '*'

What I want is E with the schema identical to A (i.e., describe E and describe A should print the exact same things).

How do I do that?

Answer1:

You can use a project-range expression to get part of the way there.

Unfortunately, there is no way to systematically strip the A:: prefix. If you know the name of the last field of A (suppose it's last), you can do this:

E = foreach D generate .. A::last;

If you wanted just the fields from B you would do

E = foreach D generate B::first ..;

If you really need to apply a specific schema, perhaps you could just define a macro that applies this schema whenever you need it, so you can overwrite any of the changes that come from grouping, joining, etc.

Answer2:

There is no way to have a common alias name after joining. but you can generate specific columns from the join results. For Example,

A = load 'data1' as (id,name,addr); B = load 'data2' as (id,name2,addr2); C = join A by id,B by id; //Now C has id,name,addr,id,name2,addr2 D = Foreach C generate($0,$1,$2);

Now the relation D has the 'A' relation columns such as id,name,addr only.

Recommend

  • How to negative match regex in JavaScript string replace? [duplicate]
  • Grails 3 - How to publish to Artifactory
  • Efficiently reading a csv file with windows newline on linux in Python
  • How to get the index of element in the List in c#
  • Android application not restoring state when installed from .apk, works fine from eclipse
  • Search files(key) in s3 bucket takes longer time
  • What does Main.1 output file do in XCode?
  • Android: How to correctly use NotifyDataSetChanged with SimpleExpandableListAdapter?
  • Less Conflicting Session Manager for Zope 2
  • Python cosine function precision [duplicate]
  • HttpClient: disabling chunked encoding
  • How do I mock an exported typescript function in a jasmine test?
  • Git describe fails to return most recent annotated tag
  • NUnit 3.0 TestCase const custom object arguments
  • Plotting line graph with factors in R
  • Trying to get the char code of ENTER key
  • Validate child input components on submit with Vee-Validate and vue js 2
  • Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
  • What is the purpose of TaskExecutor in spring?
  • Excel's Macro-Recorder usage
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • Moving mysql files across servers
  • Can I check if a recipient has an automatic reply before I send an email?
  • FFmpeg Conversion Error
  • Retrieving value from sql ExecuteScalar()
  • What is Eclipse's Declaration View used for?
  • angularjs unit test when to use $rootScope.$new()
  • How to handle AllServersUnavailable Exception
  • How to model a transition system with SPIN
  • VBA Convert delimiter text file to Excel
  • Jquery - Jquery Wysiwyg return html as a string
  • align graphs with different xlab
  • Return words with double consecutive letters
  • SVN: Merging two branches together
  • KeystoneJS: Relationships in Admin UI not updating
  • Hits per day in Google Big Query
  • Append folder name and increment by 1 using batch script
  • Checking variable from a different class in C#
  • Reading document lines to the user (python)
  • Python/Django TangoWithDjango Models and Databases