Class CreateExternalTable


  • public class CreateExternalTable
    extends Command
    A class for the CreateExternalTable command
    Author:
    xma
    • 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 from
        snowflakeConf - - 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 from
        snowflakeConf - The configuration for Snowflake Hive metastore listener
        hiveConf - The Hive configuration
        canReplace - 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 from
        snowflakeConf - 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 column
        columnPosition - Position of this column (used for CSV columns only). Zero-based.
        snowflakeFileFormatType - Snowflake's file format type
        snowflakeConf - 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:
        generateSqlQueries in class Command
        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 invalid
        IllegalArgumentException - Thrown when arguments are illegal