Skip to main content

Create procedure

  • January 15, 2014
  • 3 replies
  • 18 views

Naveen_Kumar
Forum|alt.badge.img+1
Is it any way to  create procedures like to covert a bunch of json files to a flex table ?

3 replies

Forum|alt.badge.img+2
  • Participating Frequently
  • January 15, 2014
Hi Naveen,

Could you clarify exactly what you're trying to do?

Generally you would use a COPY statement for this purpose.  Just give COPY the list of all files that you want to load; it will load them all automatically.  COPY supports glob expansion, too, if it's easier to do "COPY t FROM '/data/*.json'" than "COPY t FROM '/data/1.json', '/data/2.json', '/data/3.json'".

Adam

Naveen_Kumar
Forum|alt.badge.img+1
  • Author
  • Participating Frequently
  • January 16, 2014
Yea , thank you.
but what if we want to make different flex table for corresponding json file.means one to one mapping. we can give the flex table name as time_stamp.

Forum|alt.badge.img+2
  • Participating Frequently
  • January 16, 2014
Personally, for that use case, I'd suggest just loading into one big table.  Then partition by date; put views on top; etc.  Make "file_name" a column; you can do that with COPY as well, use a COPY expression and the magic builtin "current_load_source()" function.

This would be very expensive in most databases.  In Vertica, you'll find that it works quite nicely; because of our design, it's something that we're able to do very well.

If you really do want multiple tables, you could write a shell script to figure things out:

https://my.vertica.com/docs/7.0.x/HTML/index.htm#Authoring/ProgrammersGuide/StoredProcedures/Creatin...

Adam