Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
fix: For new publisher fix error handling for already created constra…
Browse files Browse the repository at this point in the history
…ints/indices (amundsen-io#1963)

* Fix error handling for already created constraints/indices

Signed-off-by: Kristen Armes <[email protected]>

* Bump databuilder version

Signed-off-by: Kristen Armes <[email protected]>

Signed-off-by: Kristen Armes <[email protected]>
  • Loading branch information
kristenarmes authored Aug 17, 2022
1 parent 2cf51a8 commit e9e07f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion databuilder/databuilder/utils/publisher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

LOGGER = logging.getLogger(__name__)

NEO4J_EQUIVALENT_SCHEMA_RULE_ALREADY_EXISTS_ERROR_CODE = 'Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists'
NEO4J_INDEX_ALREADY_EXISTS_ERROR_CODE = 'Neo.ClientError.Schema.IndexWithNameAlreadyExists'


def chunkify_list(records: List[dict], chunk_size: int) -> Iterator[List[dict]]:
"""
Expand Down Expand Up @@ -55,7 +58,8 @@ def create_neo4j_node_key_constraint(node_file: str,

session.write_transaction(execute_neo4j_statement, create_stmt)
except Neo4jError as e:
if 'An equivalent constraint already exists' not in e.__str__():
if e.code != NEO4J_EQUIVALENT_SCHEMA_RULE_ALREADY_EXISTS_ERROR_CODE\
and e.code != NEO4J_INDEX_ALREADY_EXISTS_ERROR_CODE:
raise
# Else, swallow the exception, to make this function idempotent.
labels.add(label)
Expand Down
2 changes: 1 addition & 1 deletion databuilder/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from setuptools import find_packages, setup

__version__ = '7.2.0'
__version__ = '7.2.1'

requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'requirements.txt')
Expand Down

0 comments on commit e9e07f0

Please sign in to comment.