[ 
https://issues.apache.org/jira/browse/ATLAS-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15067841#comment-15067841
 ] 

Hemanth Yamijala commented on ATLAS-409:
----------------------------------------

Hi [~dossett], tried to write a test that would simulate this condition. The 
testcase was like this:

{code}
    @Test
    public void testCreateTableWithNoColumns() throws Exception {
        String dbName = createDatabase();
        String tableName = tableName();
        ClassLoader classLoader = getClass().getClassLoader();
        String absolutePath = new 
File(classLoader.getResource("test.asvc").getFile()).getAbsolutePath();
        runCommand(String.format("create table %s.%s row format serde 
\'org.apache.hadoop.hive.serde2.avro.AvroSerDe\' " +
                "tblproperties('avro.schema.url'='%s')", dbName, tableName, 
absolutePath));

        assertTableIsRegistered(dbName, tableName);
    }
{code}

However, I was not able to create a test with no columns in the Hive Storage 
Description. I tried to create an Avro file of this nature:
{code}
{
    "namespace": "com.dsinpractice.samples.hadoop.avro",
    "type": "record",
    "name": "User",
    "fields": []
}
{code}

But running a hive command, even in Hive, with this kind of schema is failing: 
{code}
FAILED: Execution Error, return code 1 from 
org.apache.hadoop.hive.ql.exec.DDLTask. 
org.apache.hadoop.hive.ql.metadata.HiveException: at least one column must be 
specified for the table
{code}

Can you please confirm if it is possible to define an Avro schema with no 
fields? If you can upload such a file (like your test_serializer), I can try 
and run the test for you. Hope this helps.

> Atlas will not import hive tables with no columns
> -------------------------------------------------
>
>                 Key: ATLAS-409
>                 URL: https://issues.apache.org/jira/browse/ATLAS-409
>             Project: Atlas
>          Issue Type: Bug
>    Affects Versions: 0.6-incubating
>            Reporter: Aaron Dossett
>            Assignee: Aaron Dossett
>         Attachments: ATLAS-409.patch
>
>
> Atlas won't import a Hive table with no columns (see below for an example of 
> a valid hive table with no explicit columns).  This is because the Atlas Hive 
> Storage Descriptor class REQUIRES columns, but the Hive Table class allows 
> them to be OPTIONAL.
> {code}
> CREATE TABLE example
>   ROW FORMAT SERDE
>   'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
>   STORED AS INPUTFORMAT
>   'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
>   OUTPUTFORMAT
>   'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
>   TBLPROPERTIES (
>     'avro.schema.url'='file:///path/to/the/schema/test_serializer.avsc');
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to