omnata-plugin-runtime 0.3.21a64__py3-none-any.whl → 0.3.22a66__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1181,29 +1181,47 @@ class InboundSyncRequest(SyncRequest):
1181
1181
  else:
1182
1182
  results_df["APP_IDENTIFIER"] = None
1183
1183
  if primary_key_field is not None:
1184
- # the primary key field could contain a nested field, so we need to check for that
1185
- # we need to check that each record in the results contains the primary key field
1186
- if not all(
1187
- primary_key_field in record["RECORD_DATA"]
1188
- for record in records
1189
- ):
1190
- if "." in primary_key_field:
1191
- primary_key_field = primary_key_field.split(".")
1192
-
1193
- if not all(
1194
- get_nested_value(record["RECORD_DATA"], primary_key_field)
1195
- for record in records
1196
- ):
1184
+ if isinstance(primary_key_field,list):
1185
+ primary_key_fields = cast(List[str],primary_key_field)
1186
+ primary_key_fields = sorted(primary_key_fields)
1187
+ # handle the sitation where the primary key is a list of fields
1188
+ # first, check that all records contain all of the primary key fields
1189
+ if not all(
1190
+ all(
1191
+ field in record["RECORD_DATA"]
1192
+ for field in primary_key_fields
1193
+ )
1194
+ for record in records
1195
+ ):
1196
+ raise ValueError(
1197
+ f"Primary key fields '{primary_key_fields}' were not present in all records for stream {stream_name}"
1198
+ )
1199
+ # concatenate the primary key fields to form the APP_IDENTIFIER
1200
+ results_df["APP_IDENTIFIER"] = results_df["RECORD_DATA"].apply(lambda x: "-".join([str(field) for field in primary_key_fields]))
1201
+ else:
1202
+ # the primary key field could contain a nested field, so we need to check for that
1203
+ # we need to check that each record in the results contains the primary key field
1204
+ if not all(
1205
+ primary_key_field in record["RECORD_DATA"]
1206
+ for record in records
1207
+ ):
1208
+ if "." in primary_key_field:
1209
+ primary_key_field = primary_key_field.split(".")
1210
+
1211
+ if not all(
1212
+ get_nested_value(record["RECORD_DATA"], primary_key_field)
1213
+ for record in records
1214
+ ):
1215
+ raise ValueError(
1216
+ f"Primary key field '{primary_key_field}' was not present in all records for stream {stream_name}"
1217
+ )
1218
+ else:
1197
1219
  raise ValueError(
1198
1220
  f"Primary key field '{primary_key_field}' was not present in all records for stream {stream_name}"
1199
1221
  )
1200
- else:
1201
- raise ValueError(
1202
- f"Primary key field '{primary_key_field}' was not present in all records for stream {stream_name}"
1203
- )
1204
- # TODO: handle the scenario where the primary key field is a list, and concatenate the values to form the APP_IDENTIFIER
1205
- # Currently this is only implemented in the java runtime, since it's typically databases that use composite keys
1206
- results_df["APP_IDENTIFIER"] = results_df["RECORD_DATA"].apply(lambda x: get_nested_value(dict(x),primary_key_field))
1222
+ # TODO: handle the scenario where the primary key field is a list, and concatenate the values to form the APP_IDENTIFIER
1223
+ # Currently this is only implemented in the java runtime, since it's typically databases that use composite keys
1224
+ results_df["APP_IDENTIFIER"] = results_df["RECORD_DATA"].apply(lambda x: get_nested_value(dict(x),primary_key_field))
1207
1225
  # ensure APP_IDENTIFIER is a string
1208
1226
  results_df["APP_IDENTIFIER"] = results_df["APP_IDENTIFIER"].apply(str)
1209
1227
  # the timestamps in Snowflake are TIMESTAMP_LTZ, so we upload in string format to ensure the
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.3.21a64
3
+ Version: 0.3.22a66
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=_N5ok5LN7GDO4J9n3yduXp3tpjmhpySY__U2baiygrs,
3
3
  omnata_plugin_runtime/configuration.py,sha256=7cMekoY8CeZAJHpASU6tCMidF55Hzfr7CD74jtebqIY,35742
4
4
  omnata_plugin_runtime/forms.py,sha256=pw_aKVsXSz47EP8PFBI3VDwdSN5IjvZxp8JTjO1V130,18421
5
5
  omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
6
- omnata_plugin_runtime/omnata_plugin.py,sha256=ArEtB7LvbLBq9u39Y_2ivg24Hi1Xe-kcnzj5UG4mLP0,100971
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=qT_ILp47Y0Na3ts7lQR0rlHd5n7DZZ0EbFMkW06JwQo,102159
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=s-SrUnXaS6FaBq1igiJhcCB3Md_a6op-dp_g1H_55QU,27736
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=se6MftQI5NrVHaLb1hByPCgAESPQhkAgIG7KIU1clDU,16562
9
- omnata_plugin_runtime-0.3.21a64.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.3.21a64.dist-info/METADATA,sha256=AN68hzVHcChygxFH76s7iZtvROwge5NqHDNttfkRfko,1604
11
- omnata_plugin_runtime-0.3.21a64.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.3.21a64.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.3.22a66.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.3.22a66.dist-info/METADATA,sha256=kXXYPQoia3W6E2x3OmgF8v9vQnMdGOtt4aY-h7D0lPE,1604
11
+ omnata_plugin_runtime-0.3.22a66.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.3.22a66.dist-info/RECORD,,