Skip to content

Commit

Permalink
Fix bug where column spec cannot be updated without type_code (google…
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander authored and Lars Wander committed Jul 1, 2019
1 parent 3709c09 commit ff9c186
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions automl/google/cloud/automl_v1beta1/helper/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def __dataset_name_from_args(self, dataset=None, dataset_display_name=None,

if dataset_name is None:
if dataset is None:
dataset = get_dataset(
dataset_display_name=datatset_display_name,
dataset = self.get_dataset(
dataset_display_name=dataset_display_name,
project=project,
region=region
)
Expand All @@ -106,8 +106,8 @@ def __model_name_from_args(self, model=None, model_display_name=None,

if model_name is None:
if model is None:
model = get_model(
model_display_name=datatset_display_name,
model = self.get_model(
model_display_name=dataset_display_name,
project=project,
region=region
)
Expand Down Expand Up @@ -580,11 +580,23 @@ def update_column_spec(self, dataset=None, dataset_display_name=None,
region=region
)

# type code must always be set
if type_code is None:
type_code = {s.name: s for s in self.list_column_specs(
dataset=dataset,
dataset_display_name=dataset_display_name,
dataset_name=dataset_name,
table_spec_name=table_spec_name,
table_spec_index=table_spec_index,
project=project,
region=region)
}[column_spec_name].data_type.type_code

data_type = {}
if nullable is not None:
data_type['nullable'] = nullable
if type_code is not None:
data_type['type_code'] = type_code

data_type['type_code'] = type_code

request = {
'name': column_spec_name,
Expand Down

0 comments on commit ff9c186

Please sign in to comment.