-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding method to add columns to a table (#18)
- Loading branch information
Showing
4 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Use the builders for creating Column thrift object. | ||
Some arguments are optional when creating a thrift object. | ||
Check Builder constructor for more information. | ||
""" | ||
|
||
from hive_metastore_client.builders.column_builder import ColumnBuilder | ||
from hive_metastore_client.hive_mestastore_client import HiveMetastoreClient | ||
|
||
HIVE_HOST = "<ADD_HIVE_HOST_HERE>" | ||
HIVE_PORT = 9083 | ||
|
||
# You must create a list with the columns | ||
columns = [ | ||
ColumnBuilder(name="quantity", type="int", comment="item's quantity").build() | ||
] | ||
|
||
with HiveMetastoreClient(HIVE_HOST, HIVE_PORT) as hive_client: | ||
# Adding columns to the table | ||
hive_client.add_columns_to_table( | ||
db_name="store", table_name="order", columns=columns | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
""" | ||
Use the builders for creating Database thrift object. | ||
Some arguments are optional when creating a thrift object. | ||
Check Builder constructor for more information. | ||
""" | ||
|
||
from hive_metastore_client.builders.database_builder import DatabaseBuilder | ||
from hive_metastore_client.hive_mestastore_client import HiveMetastoreClient | ||
|
||
HIVE_HOST = "<ADD_HIVE_HOST_HERE>" | ||
HIVE_PORT = 9083 | ||
|
||
with HiveMetastoreClient(HIVE_HOST, HIVE_PORT) as hive_client: | ||
|
||
database_builder = DatabaseBuilder("database_name") | ||
database = database_builder.build() | ||
# Creating database object using builder | ||
database = DatabaseBuilder("database_name").build() | ||
|
||
with HiveMetastoreClient(HIVE_HOST, HIVE_PORT) as hive_client: | ||
# Creating new database from thrift table object | ||
hive_client.create_database(database) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters