Glue: get_table() should return latest version (#6006)
This commit is contained in:
parent
a1a43e3f74
commit
96b8e12d45
@ -840,7 +840,8 @@ class FakeTable(BaseModel):
|
|||||||
def delete_version(self, version_id):
|
def delete_version(self, version_id):
|
||||||
self.versions.pop(version_id)
|
self.versions.pop(version_id)
|
||||||
|
|
||||||
def as_dict(self, version=1):
|
def as_dict(self, version=None):
|
||||||
|
version = version or self._current_version
|
||||||
obj = {
|
obj = {
|
||||||
"DatabaseName": self.database_name,
|
"DatabaseName": self.database_name,
|
||||||
"Name": self.name,
|
"Name": self.name,
|
||||||
|
@ -319,6 +319,11 @@ def test_get_table_versions():
|
|||||||
helpers.create_table(client, database_name, table_name, table_input)
|
helpers.create_table(client, database_name, table_name, table_input)
|
||||||
version_inputs["1"] = table_input
|
version_inputs["1"] = table_input
|
||||||
|
|
||||||
|
# Get table should retrieve the first version
|
||||||
|
table = client.get_table(DatabaseName=database_name, Name=table_name)["Table"]
|
||||||
|
table["StorageDescriptor"]["Columns"].should.equal([])
|
||||||
|
table["VersionId"].should.equal("1")
|
||||||
|
|
||||||
columns = [{"Name": "country", "Type": "string"}]
|
columns = [{"Name": "country", "Type": "string"}]
|
||||||
table_input = helpers.create_table_input(database_name, table_name, columns=columns)
|
table_input = helpers.create_table_input(database_name, table_name, columns=columns)
|
||||||
helpers.update_table(client, database_name, table_name, table_input)
|
helpers.update_table(client, database_name, table_name, table_input)
|
||||||
@ -354,6 +359,15 @@ def test_get_table_versions():
|
|||||||
ver["Table"]["Name"].should.equal(table_name)
|
ver["Table"]["Name"].should.equal(table_name)
|
||||||
ver["Table"]["StorageDescriptor"]["Columns"].should.equal(columns)
|
ver["Table"]["StorageDescriptor"]["Columns"].should.equal(columns)
|
||||||
|
|
||||||
|
# get_table should retrieve the latest version
|
||||||
|
table = client.get_table(DatabaseName=database_name, Name=table_name)["Table"]
|
||||||
|
table["StorageDescriptor"]["Columns"].should.equal(columns)
|
||||||
|
table["VersionId"].should.equal("3")
|
||||||
|
|
||||||
|
table = client.get_tables(DatabaseName=database_name)["TableList"][0]
|
||||||
|
table["StorageDescriptor"]["Columns"].should.equal(columns)
|
||||||
|
table["VersionId"].should.equal("3")
|
||||||
|
|
||||||
|
|
||||||
@mock_glue
|
@mock_glue
|
||||||
def test_get_table_version_not_found():
|
def test_get_table_version_not_found():
|
||||||
|
Loading…
Reference in New Issue
Block a user