Skip to content

Commit

Permalink
ensure internal id string
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Sep 29, 2023
1 parent c0b87bf commit a5d7692
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions taxonomies/trees/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,16 @@ def postflow(self):
)


class EnsureInternalIdString(BaseEnricher):
class EnsureInternalIdString(ColumnTypeTester):

FIELD_NAME = 'meta-internal-id',

def test(self):
return True

def fix_internal_id(self):
def predicate():
def func(dp):
all_fields = [f['name'] for f in dp.descriptor['resources'][0]['schema']['fields']]
return self.FIELD_NAME in all_fields
return func
return DF.conditional(
predicate(),
DF.Flow(
DF.set_type(self.FIELD_NAME, type='number', transform=lambda x: str(x) if x is not None else None)
)
)
REQUIRED_COLUMN_TYPES = [
'meta:internal-id',
]
PROHIBITED_COLUMN_TYPES = []

def postflow(self):
def conditional(self):
return DF.Flow(
self.fix_internal_id(),
DF.set_type('meta-internal-id', type='string', transform=lambda v: str(v) if v is not None else None)
)


Expand Down

0 comments on commit a5d7692

Please sign in to comment.