Last active
June 29, 2021 23:25
-
-
Save nfarah86/5719205c901fb9731519d7235e2188c0 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
rs = Client(api_server='api.rs2.usw2.rockset.com', api_key='APIKEY') | |
mappings = [ | |
rs.FieldMapping.mapping( | |
name="twitchTransformation1", | |
input_fields=[ | |
rs.FieldMapping.input_field( | |
field_name="price", | |
if_missing="SKIP", | |
is_drop=True, | |
param="price" | |
) | |
], | |
output_field=rs.FieldMapping.output_field( | |
field_name="price", | |
sql_expression="TRY_CAST(REGEXP_REPLACE(:price, '[^\d.]') as float)", | |
on_error="FAIL" | |
) | |
), | |
rs.FieldMapping.mapping( | |
name="twitchTransformation2", | |
input_fields=[ | |
rs.FieldMapping.input_field( | |
field_name="latitude", | |
if_missing="SKIP", | |
is_drop=True, | |
param="latitude" | |
) | |
], | |
output_field=rs.FieldMapping.output_field( | |
field_name="latitude", | |
sql_expression="TRY_CAST(:latitude as float)", | |
on_error="FAIL" | |
) | |
) | |
] | |
# create our collection | |
new_collection = rs.Collection.create("codeDemoFieldMappingsTwitch1", field_mappings=mappings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment