<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">

<document>
  <header>
    <title>PUT ddl/database/:db/table/:existingtable/like/:newtable</title>
  </header>

  <body>
  <section>
   <title>Description</title>
    <p>Create a new HCatalog table like an existing one</p>
  </section>

  <section>
   <title>URL</title>
    <p><code>http://</code>www.myserver.com<code>/templeton/v1/ddl/database/</code>:db<code>/table/</code>:existingtable<code>/like/</code>:newtable</p>
  </section>

  <section>
   <title>Parameters</title>
    <table>
    <tr><th>Name</th><th>Description</th><th>Required?</th><th>Default</th></tr>

    <tr><td><strong>:db</strong></td>
        <td>The database name</td>
        <td>Required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>:existingtable</strong></td>
        <td>The existing table name</td>
        <td>Required</td>
        <td>None</td>
    </tr>

    <tr><td><strong>:newtable</strong></td>
        <td>The new table name.</td>
        <td>Required</td>
        <td>None</td>
    </tr>

   <tr><td><strong>group</strong></td>
        <td>The user group to use when creating a table</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>permissions</strong></td>
        <td>The permissions string to use when creating a table.</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    <tr><td><strong>external</strong></td>
        <td>Allows you to specify a location so that Hive does not use the default
            location for this table.</td>
        <td>Optional</td>
        <td>false</td>
    </tr>

    <tr><td><strong>ifNotExists</strong></td>
        <td>If true, you will not receive an error if the table already exists.</td>
        <td>Optional</td>
        <td>false</td>
    </tr>

    <tr><td><strong>location</strong></td>
        <td>The HDFS path</td>
        <td>Optional</td>
        <td>None</td>
    </tr>

    </table>
  </section>

  <section>
   <title>Results</title>
    <table>
    <tr><th>Name</th><th>Description</th></tr>

    <tr><td><strong>table</strong></td>
        <td>The new table name</td>
    </tr>

    <tr><td><strong>database</strong></td>
        <td>The database name</td>
    </tr>

    </table>
 </section>

  <section>
   <title>Example</title>

   <p><strong>Curl Command</strong></p>
<source>
% curl -s -X PUT -HContent-type:application/json -d {} \
 'http://localhost:50111/templeton/v1/ddl/database/default/table/test_table/like/test_table_2?user.name=ctdean'
</source>

   <p><strong>JSON Output</strong></p>
<source>
{
 "table": "test_table_2",
 "database": "default"
}
</source>
  </section>
 </body>
</document>
