org.apache.hadoop.hive.ql.metadata
Class Table

java.lang.Object
  extended by org.apache.hadoop.hive.ql.metadata.Table
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AuthorizationPreEventListener.TableWrapper

public class Table
extends Object
implements Serializable

A Hive Table: is a fundamental unit of data in Hive that shares a common schema/DDL. Please note that the ql code should always go through methods of this class to access the metadata, instead of directly accessing org.apache.hadoop.hive.metastore.api.Table. This helps to isolate the metastore code and the ql code.

See Also:
Serialized Form

Constructor Summary
Table()
          Used only for serialization.
Table(String databaseName, String tableName)
           
Table(org.apache.hadoop.hive.metastore.api.Table table)
           
 
Method Summary
 boolean canDrop()
           
 boolean canWrite()
           
 void checkValidity()
           
 void clearSerDeInfo()
           
 Table copy()
           
 LinkedHashMap<String,String> createSpec(org.apache.hadoop.hive.metastore.api.Partition tp)
          Creates a partition name -> value spec map object
 boolean equals(Object obj)
           
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getAllCols()
          Returns a list of all the columns of the table (data columns + partition columns in that order.
 List<org.apache.hadoop.hive.metastore.api.Index> getAllIndexes(short max)
           
 List<String> getBucketCols()
           
 String getBucketingDimensionId()
           
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getCols()
           
 String getCompleteName()
           
 org.apache.hadoop.fs.Path getDataLocation()
           
 String getDbName()
           
 Deserializer getDeserializer()
           
static org.apache.hadoop.hive.metastore.api.Table getEmptyTable(String databaseName, String tableName)
          Initialize an emtpy table.
 StructField getField(String fld)
           
 ArrayList<StructField> getFields()
           
 Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()
           
 int getLastAccessTime()
           
 Properties getMetadata()
           
 int getNumBuckets()
           
 Class<? extends HiveOutputFormat> getOutputFormatClass()
           
 String getOwner()
           
 Map<String,String> getParameters()
           
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getPartCols()
           
 List<org.apache.hadoop.hive.metastore.api.FieldSchema> getPartitionKeys()
           
 org.apache.hadoop.fs.Path getPath()
           
 String getProperty(String name)
           
 ProtectMode getProtectMode()
           
 int getRetention()
           
 String getSerdeParam(String param)
           
 String getSerializationLib()
           
 List<String> getSkewedColNames()
           
 Map<List<String>,String> getSkewedColValueLocationMaps()
           
 List<List<String>> getSkewedColValues()
           
 org.apache.hadoop.hive.metastore.api.SkewedInfo getSkewedInfo()
           
 List<org.apache.hadoop.hive.metastore.api.Order> getSortCols()
           
 org.apache.hadoop.fs.FileStatus[] getSortedPaths()
           
 HiveStorageHandler getStorageHandler()
           
 String getTableName()
           
 TableType getTableType()
           
 org.apache.hadoop.hive.metastore.api.Table getTTable()
          This function should only be used in serialization.
 String getViewExpandedText()
           
 String getViewOriginalText()
           
 int hashCode()
           
 boolean isDummyTable()
           
 boolean isImmutable()
           
 boolean isIndexTable()
           
 boolean isNonNative()
           
 boolean isOffline()
           
 boolean isPartitioned()
           
 boolean isPartitionKey(String colName)
           
 boolean isStoredAsSubDirectories()
           
 boolean isView()
           
 void setBucketCols(List<String> bucketCols)
           
 void setCreateTime(int createTime)
           
 void setDataLocation(org.apache.hadoop.fs.Path path)
           
 void setDbName(String databaseName)
           
 void setFields(List<org.apache.hadoop.hive.metastore.api.FieldSchema> fields)
           
 void setInputFormatClass(Class<? extends org.apache.hadoop.mapred.InputFormat> inputFormatClass)
           
 void setInputFormatClass(String name)
           
 void setLastAccessTime(int lastAccessTime)
           
 void setNumBuckets(int nb)
           
 void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass)
           
 void setOutputFormatClass(String name)
           
 void setOwner(String owner)
           
 void setPartCols(List<org.apache.hadoop.hive.metastore.api.FieldSchema> partCols)
           
 void setProperty(String name, String value)
           
 void setProtectMode(ProtectMode protectMode)
           
 void setRetention(int retention)
           
 String setSerdeParam(String param, String value)
           
 void setSerializationLib(String lib)
           
 void setSkewedColNames(List<String> skewedColNames)
           
 void setSkewedColValues(List<List<String>> skewedValues)
           
 void setSkewedInfo(org.apache.hadoop.hive.metastore.api.SkewedInfo skewedInfo)
           
 void setSkewedValueLocationMap(List<String> valList, String dirName)
           
 void setSortCols(List<org.apache.hadoop.hive.metastore.api.Order> sortOrder)
           
 void setStoredAsSubDirectories(boolean storedAsSubDirectories)
           
 void setTableName(String tableName)
           
 void setTableType(TableType tableType)
           
 void setTTable(org.apache.hadoop.hive.metastore.api.Table tTable)
          This function should only be called by Java serialization.
 void setViewExpandedText(String viewExpandedText)
           
 void setViewOriginalText(String viewOriginalText)
           
 String toString()
           
 void unsetDataLocation()
           
 void validatePartColumnNames(Map<String,String> spec, boolean shouldBeFull)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table()
Used only for serialization.


Table

public Table(org.apache.hadoop.hive.metastore.api.Table table)

Table

public Table(String databaseName,
             String tableName)
Method Detail

isDummyTable

public boolean isDummyTable()

getTTable

public org.apache.hadoop.hive.metastore.api.Table getTTable()
This function should only be used in serialization. We should never call this function to modify the fields, because the cached fields will become outdated.


setTTable

public void setTTable(org.apache.hadoop.hive.metastore.api.Table tTable)
This function should only be called by Java serialization.


getEmptyTable

public static org.apache.hadoop.hive.metastore.api.Table getEmptyTable(String databaseName,
                                                                       String tableName)
Initialize an emtpy table.


checkValidity

public void checkValidity()
                   throws HiveException
Throws:
HiveException

setInputFormatClass

public void setInputFormatClass(Class<? extends org.apache.hadoop.mapred.InputFormat> inputFormatClass)

setOutputFormatClass

public void setOutputFormatClass(Class<? extends HiveOutputFormat> outputFormatClass)

getMetadata

public final Properties getMetadata()

getPath

public final org.apache.hadoop.fs.Path getPath()

getTableName

public final String getTableName()

getDataLocation

public final org.apache.hadoop.fs.Path getDataLocation()

getDeserializer

public final Deserializer getDeserializer()

getStorageHandler

public HiveStorageHandler getStorageHandler()

getInputFormatClass

public final Class<? extends org.apache.hadoop.mapred.InputFormat> getInputFormatClass()

getOutputFormatClass

public final Class<? extends HiveOutputFormat> getOutputFormatClass()

validatePartColumnNames

public final void validatePartColumnNames(Map<String,String> spec,
                                          boolean shouldBeFull)
                                   throws SemanticException
Throws:
SemanticException

setProperty

public void setProperty(String name,
                        String value)

getProperty

public String getProperty(String name)

isImmutable

public boolean isImmutable()

setTableType

public void setTableType(TableType tableType)

getTableType

public TableType getTableType()

getFields

public ArrayList<StructField> getFields()

getField

public StructField getField(String fld)

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getPartCols

public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getPartCols()

isPartitionKey

public boolean isPartitionKey(String colName)

getBucketingDimensionId

public String getBucketingDimensionId()

setDataLocation

public void setDataLocation(org.apache.hadoop.fs.Path path)

unsetDataLocation

public void unsetDataLocation()

setBucketCols

public void setBucketCols(List<String> bucketCols)
                   throws HiveException
Throws:
HiveException

setSortCols

public void setSortCols(List<org.apache.hadoop.hive.metastore.api.Order> sortOrder)
                 throws HiveException
Throws:
HiveException

setSkewedValueLocationMap

public void setSkewedValueLocationMap(List<String> valList,
                                      String dirName)
                               throws HiveException
Throws:
HiveException

getSkewedColValueLocationMaps

public Map<List<String>,String> getSkewedColValueLocationMaps()

setSkewedColValues

public void setSkewedColValues(List<List<String>> skewedValues)
                        throws HiveException
Throws:
HiveException

getSkewedColValues

public List<List<String>> getSkewedColValues()

setSkewedColNames

public void setSkewedColNames(List<String> skewedColNames)
                       throws HiveException
Throws:
HiveException

getSkewedColNames

public List<String> getSkewedColNames()

getSkewedInfo

public org.apache.hadoop.hive.metastore.api.SkewedInfo getSkewedInfo()

setSkewedInfo

public void setSkewedInfo(org.apache.hadoop.hive.metastore.api.SkewedInfo skewedInfo)
                   throws HiveException
Throws:
HiveException

isStoredAsSubDirectories

public boolean isStoredAsSubDirectories()

setStoredAsSubDirectories

public void setStoredAsSubDirectories(boolean storedAsSubDirectories)
                               throws HiveException
Throws:
HiveException

getCols

public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getCols()

getAllCols

public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getAllCols()
Returns a list of all the columns of the table (data columns + partition columns in that order.

Returns:
List

setPartCols

public void setPartCols(List<org.apache.hadoop.hive.metastore.api.FieldSchema> partCols)

getDbName

public String getDbName()

getNumBuckets

public int getNumBuckets()

setInputFormatClass

public void setInputFormatClass(String name)
                         throws HiveException
Throws:
HiveException

setOutputFormatClass

public void setOutputFormatClass(String name)
                          throws HiveException
Throws:
HiveException

isPartitioned

public boolean isPartitioned()

setFields

public void setFields(List<org.apache.hadoop.hive.metastore.api.FieldSchema> fields)

setNumBuckets

public void setNumBuckets(int nb)

getOwner

public String getOwner()
Returns:
The owner of the table.
See Also:
Table.getOwner()

getParameters

public Map<String,String> getParameters()
Returns:
The table parameters.
See Also:
Table.getParameters()

getRetention

public int getRetention()
Returns:
The retention on the table.
See Also:
Table.getRetention()

setOwner

public void setOwner(String owner)
Parameters:
owner -
See Also:
Table.setOwner(java.lang.String)

setRetention

public void setRetention(int retention)
Parameters:
retention -
See Also:
Table.setRetention(int)

setSerializationLib

public void setSerializationLib(String lib)

getSerializationLib

public String getSerializationLib()

getSerdeParam

public String getSerdeParam(String param)

setSerdeParam

public String setSerdeParam(String param,
                            String value)

getBucketCols

public List<String> getBucketCols()

getSortCols

public List<org.apache.hadoop.hive.metastore.api.Order> getSortCols()

setTableName

public void setTableName(String tableName)

setDbName

public void setDbName(String databaseName)

getPartitionKeys

public List<org.apache.hadoop.hive.metastore.api.FieldSchema> getPartitionKeys()

getViewOriginalText

public String getViewOriginalText()
Returns:
the original view text, or null if this table is not a view

setViewOriginalText

public void setViewOriginalText(String viewOriginalText)
Parameters:
viewOriginalText - the original view text to set

getViewExpandedText

public String getViewExpandedText()
Returns:
the expanded view text, or null if this table is not a view

clearSerDeInfo

public void clearSerDeInfo()

setViewExpandedText

public void setViewExpandedText(String viewExpandedText)
Parameters:
viewExpandedText - the expanded view text to set

isView

public boolean isView()
Returns:
whether this table is actually a view

isIndexTable

public boolean isIndexTable()
Returns:
whether this table is actually an index table

createSpec

public LinkedHashMap<String,String> createSpec(org.apache.hadoop.hive.metastore.api.Partition tp)
Creates a partition name -> value spec map object

Parameters:
tp - Use the information from this partition.
Returns:
Partition name to value mapping.

copy

public Table copy()
           throws HiveException
Throws:
HiveException

setCreateTime

public void setCreateTime(int createTime)

getLastAccessTime

public int getLastAccessTime()

setLastAccessTime

public void setLastAccessTime(int lastAccessTime)

isNonNative

public boolean isNonNative()

setProtectMode

public void setProtectMode(ProtectMode protectMode)
Parameters:
protectMode -

getProtectMode

public ProtectMode getProtectMode()
Returns:
protect mode

isOffline

public boolean isOffline()
Returns:
True protect mode indicates the table if offline.

canDrop

public boolean canDrop()
Returns:
True if protect mode attribute of the partition indicate that it is OK to drop the partition

canWrite

public boolean canWrite()
Returns:
True if protect mode attribute of the table indicate that it is OK to write the table

getCompleteName

public String getCompleteName()
Returns:
include the db name

getAllIndexes

public List<org.apache.hadoop.hive.metastore.api.Index> getAllIndexes(short max)
                                                               throws HiveException
Returns:
List containing Indexes names if there are indexes on this table
Throws:
HiveException

getSortedPaths

public org.apache.hadoop.fs.FileStatus[] getSortedPaths()


Copyright © 2014 The Apache Software Foundation. All rights reserved.