Created
July 2, 2021 16:11
-
-
Save andreypopp/7acf111cc0007117ee1197a05885e02b to your computer and use it in GitHub Desktop.
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
diff --git a/src/rex.tabular_import/src/rex/tabular_import/ctl.py b/src/rex.tabular_import/src/rex/tabular_import/ctl.py | |
index 9bd58acf8..4e03d0a39 100644 | |
--- a/src/rex.tabular_import/src/rex/tabular_import/ctl.py | |
+++ b/src/rex.tabular_import/src/rex/tabular_import/ctl.py | |
@@ -142,7 +142,7 @@ class TabularImportTask(RexTask): | |
update_bool=self.update, | |
) | |
except Exception as exc: | |
- raise Error(str(exc)) from None | |
+ raise Error("Error during tabular data import") from exc | |
else: | |
log('%s records imported into %s' % ( | |
num_imported, | |
diff --git a/src/rex.tabular_import/src/rex/tabular_import/load.py b/src/rex.tabular_import/src/rex/tabular_import/load.py | |
index b95113578..6046d9837 100644 | |
--- a/src/rex.tabular_import/src/rex/tabular_import/load.py | |
+++ b/src/rex.tabular_import/src/rex/tabular_import/load.py | |
@@ -10,7 +10,7 @@ from htsql.core.cmd.embed import Embed | |
from htsql.tweak.etl.cmd.insert import ( | |
BuildExtractNode, BuildExtractTable, | |
BuildExecuteInsert, BuildResolveIdentity) | |
-from htsql.tweak.etl.cmd.merge import BuildExecuteUpdate, BuildResolveKey | |
+from htsql.tweak.etl.cmd.merge import BuildExecuteUpdate, BuildResolveKey, BuildExtractIdentity | |
from rex.db import get_db | |
from .error import TabularImportError | |
@@ -94,21 +94,24 @@ def update( | |
execute_update = BuildExecuteUpdate.__invoke__( | |
extract_table.table, | |
extract_table.columns) | |
+ extract_identity = BuildExtractIdentity.__invoke__( | |
+ extract_node.node, extract_node.arcs) | |
resolve_identity = BuildResolveIdentity.__invoke__( | |
execute_update.table, | |
execute_update.output_columns, | |
is_list=False) | |
resolve_key = BuildResolveKey.__invoke__( | |
- extract_node.node, None) | |
- query = query_cache[cache_key] = ( | |
- lambda values: | |
- resolve_identity( | |
- execute_update( | |
- resolve_key(values), | |
- extract_table( | |
- extract_node(values) | |
- ) | |
- ))) | |
+ extract_node.node, extract_node.arcs, False) | |
+ | |
+ def query(record): | |
+ row = extract_node(record) | |
+ update_id, _ = extract_identity(row) | |
+ key = resolve_key(update_id) | |
+ assert key is not None | |
+ row = extract_table(row) | |
+ resolve_identity(execute_update(key, row)) | |
+ | |
+ query_cache[cache_key] = query | |
query = query_cache[cache_key] | |
return query(row) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment