Class AddPartition
- java.lang.Object
-
- net.snowflake.hivemetastoreconnector.commands.Command
-
- net.snowflake.hivemetastoreconnector.commands.AddPartition
-
public class AddPartition extends Command
A class for the AddPartition command- Author:
- wwong
-
-
Constructor Summary
Constructors Constructor Description AddPartition(org.apache.hadoop.hive.metastore.api.Table hiveTable, Iterator<org.apache.hadoop.hive.metastore.api.Partition> partitionsIterator, SnowflakeConf snowflakeConf, org.apache.hadoop.conf.Configuration hiveConf, boolean isCompact)Creates an AddPartition command without an eventAddPartition(org.apache.hadoop.hive.metastore.events.AddPartitionEvent addPartitionEvent, SnowflakeConf snowflakeConf)Creates an AddPartition commandAddPartition(org.apache.hadoop.hive.metastore.events.AlterPartitionEvent alterPartitionEvent, SnowflakeConf snowflakeConf)Creates an AddPartition command
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static List<AddPartition>compact(List<AddPartition> addPartitions)Combines N add partition commands with M total partitions into ceil(M / MAX_ADDED_PARTITIONS) new add partition commands.List<String>generateSqlQueries()Generates the queries for add partition.booleanisCompact()Mthod to determine whether a command was already compacted-
Methods inherited from class net.snowflake.hivemetastoreconnector.commands.Command
getDatabaseName, getTableName
-
-
-
-
Constructor Detail
-
AddPartition
public AddPartition(org.apache.hadoop.hive.metastore.events.AddPartitionEvent addPartitionEvent, SnowflakeConf snowflakeConf)Creates an AddPartition command- Parameters:
addPartitionEvent- Event to generate a command fromsnowflakeConf- - the configuration for Snowflake Hive metastore listener
-
AddPartition
public AddPartition(org.apache.hadoop.hive.metastore.events.AlterPartitionEvent alterPartitionEvent, SnowflakeConf snowflakeConf)Creates an AddPartition command- Parameters:
alterPartitionEvent- Event to generate a command fromsnowflakeConf- - the configuration for Snowflake Hive metastore listener
-
AddPartition
public AddPartition(org.apache.hadoop.hive.metastore.api.Table hiveTable, Iterator<org.apache.hadoop.hive.metastore.api.Partition> partitionsIterator, SnowflakeConf snowflakeConf, org.apache.hadoop.conf.Configuration hiveConf, boolean isCompact)Creates an AddPartition command without an event- Parameters:
hiveTable- The Hive table to generate a command frompartitionsIterator- A method that supplies an iterator for partitions to addsnowflakeConf- - the configuration for Snowflake Hive metastore listenerhiveConf- The Hive configurationisCompact- internal marker to check if this command was generated by compaction
-
-
Method Detail
-
generateSqlQueries
public List<String> generateSqlQueries() throws SQLException
Generates the queries for add partition.- Specified by:
generateSqlQueriesin classCommand- Returns:
- The Snowflake queries generated
- Throws:
SQLException
-
compact
public static List<AddPartition> compact(List<AddPartition> addPartitions)
Combines N add partition commands with M total partitions into ceil(M / MAX_ADDED_PARTITIONS) new add partition commands. If M > N * MAX_ADDED_PARTITIONS, then the result will be more than N elements. Each command except the last one will have MAX_ADDED_PARTITIONS partitions. Assumes that the commands are all for the same table, with no modifications to the table in between- Parameters:
addPartitions- the add partition commands to combine.- Returns:
- the compacted add partition commands
-
isCompact
public boolean isCompact()
Mthod to determine whether a command was already compacted- Returns:
- whether a command was compacted
-
-