Class CreateExternalTable
- java.lang.Object
-
- net.snowflake.hivemetastoreconnector.commands.Command
-
- net.snowflake.hivemetastoreconnector.commands.CreateExternalTable
-
public class CreateExternalTable extends Command
A class for the CreateExternalTable command- Author:
- xma
-
-
Constructor Summary
Constructors Constructor Description CreateExternalTable(org.apache.hadoop.hive.metastore.api.Table hiveTable, SnowflakeConf snowflakeConf, org.apache.hadoop.conf.Configuration hiveConf, boolean canReplace)Creates a CreateExternalTable command, without an eventCreateExternalTable(org.apache.hadoop.hive.metastore.events.CreateTableEvent createTableEvent, SnowflakeConf snowflakeConf)Creates a CreateExternalTable command
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringgenerateColumnStr(org.apache.hadoop.hive.metastore.api.FieldSchema columnSchema, int columnPosition, HiveToSnowflakeType.SnowflakeFileFormatType snowflakeFileFormatType, SnowflakeConf snowflakeConf)Generate the string for a column to be used in the queryList<String>generateSqlQueries()Generates the queries for create external table The behavior of this method is as follows (in order of preference): a.static StringgenerateStageName(org.apache.hadoop.hive.metastore.api.Table hiveTable, SnowflakeConf snowflakeConf)Helper method to generate a stage name for newly created stages.-
Methods inherited from class net.snowflake.hivemetastoreconnector.commands.Command
getDatabaseName, getTableName
-
-
-
-
Constructor Detail
-
CreateExternalTable
public CreateExternalTable(org.apache.hadoop.hive.metastore.events.CreateTableEvent createTableEvent, SnowflakeConf snowflakeConf)Creates a CreateExternalTable command- Parameters:
createTableEvent- Event to generate a command fromsnowflakeConf- - the configuration for Snowflake Hive metastore listener
-
CreateExternalTable
public CreateExternalTable(org.apache.hadoop.hive.metastore.api.Table hiveTable, SnowflakeConf snowflakeConf, org.apache.hadoop.conf.Configuration hiveConf, boolean canReplace)Creates a CreateExternalTable command, without an event- Parameters:
hiveTable- The Hive table to generate a command fromsnowflakeConf- The configuration for Snowflake Hive metastore listenerhiveConf- The Hive configurationcanReplace- Whether to replace existing resources or not
-
-
Method Detail
-
generateStageName
public static String generateStageName(org.apache.hadoop.hive.metastore.api.Table hiveTable, SnowflakeConf snowflakeConf)
Helper method to generate a stage name for newly created stages.- Parameters:
hiveTable- The Hive table to generate a command fromsnowflakeConf- The configuration for Snowflake Hive metastore listener- Returns:
- The generated stage name. For example, "someDb__aTable".
-
generateColumnStr
public static String generateColumnStr(org.apache.hadoop.hive.metastore.api.FieldSchema columnSchema, int columnPosition, HiveToSnowflakeType.SnowflakeFileFormatType snowflakeFileFormatType, SnowflakeConf snowflakeConf)
Generate the string for a column to be used in the query- Parameters:
columnSchema- Details about the columncolumnPosition- Position of this column (used for CSV columns only). Zero-based.snowflakeFileFormatType- Snowflake's file format typesnowflakeConf- The configuration for Snowflake Hive metastore listener- Returns:
- Snippet of a command that represents a column, for example: col1 INT as (VALUE:c1::INT)
-
generateSqlQueries
public List<String> generateSqlQueries() throws SQLException, UnsupportedOperationException, IllegalArgumentException
Generates the queries for create external table The behavior of this method is as follows (in order of preference): a. If the user specifies an integration, use the integration to create a stage. Then, use the stage to create a table. b. If the user specifies a stage, use the stage to create a table. c. If the user allows this listener to read from Hive configs, use the AWS credentials from the Hive config to create a stage. Then, use the stage to create a table. d. Raise an error. Do not create a table.- Specified by:
generateSqlQueriesin classCommand- Returns:
- The Snowflake query generated
- Throws:
SQLException- Thrown when there was an error executing a Snowflake SQL query (if a Snowflake query must be executed).UnsupportedOperationException- Thrown when the input is invalidIllegalArgumentException- Thrown when arguments are illegal
-
-