def test_add_partition_string_key(): part_schema = ibis.schema([('foo', 'int32'), ('bar', 'string')]) stmt = ddl.AddPartition('tbl', {'foo': 5, 'bar': 'qux'}, part_schema) result = stmt.compile() expected = 'ALTER TABLE tbl ADD PARTITION (foo=5, bar="qux")' assert result == expected
def test_add_partition(part_schema, table_name): stmt = ddl.AddPartition( table_name, {'year': 2007, 'month': 4}, part_schema ) result = stmt.compile() expected = 'ALTER TABLE tbl ADD PARTITION (year=2007, month=4)' assert result == expected
def test_add_partition_with_props(part_schema, table_name): props = dict(location='/users/foo/my-data') stmt = ddl.AddPartition( table_name, {'year': 2007, 'month': 4}, part_schema, **props ) result = stmt.compile() expected = """\ ALTER TABLE tbl ADD PARTITION (year=2007, month=4) LOCATION '/users/foo/my-data'""" assert result == expected
def add_partition(self, spec, location=None): """Add a new table partition. This API creates any necessary new directories in HDFS. Partition parameters can be set in a single DDL statement or you can use `alter_partition` to set them after the fact. """ part_schema = self.partition_schema() stmt = ddl.AddPartition( self._qualified_name, spec, part_schema, location=location ) return self._client.raw_sql(stmt)