its a not via an API but what if you experimented with "create table XXX as select ..... where 1=0" followed by "desc XXX".
Maybe something like that can tide you over until a more programmatic way comes to light? On Fri, Dec 20, 2013 at 3:01 PM, Sean Colgan <sean.col...@nasdaqomx.com>wrote: > Hi all, > I'm looking for a way to automatically generate an output table schema > based on the input and query. Basically, a given input schema and SELECT > statement produce a deterministic result schema. And Hive will complain if > a given output table does not have a matching schema. Like so: > > FAILED: SemanticException [Error 10044]: Line 3:23 Cannot insert into > target table because column number/types are different 'test_out': Table > insclause-0 has 1 columns, but query has 3 columns. > > I am developing a process that will accept input data with an arbitrary > known schema, and an HQL SELECT statement to query that data. I'm looking > for a way to automatically generate the correct output table schema. I'm > starting to poke through the code in SemanticAnalyzer.java (which generates > the above error string) to see if I can use something in there. But I > certainly welcome any thoughts or suggestions on this topic. > > Thanks! > Sean > > -- > > sean.col...@nasdaqomx.com > www.nasdaqomx.com/finqloud >