Skip to content

Instantly share code, notes, and snippets.

@mshakhomirov
Created November 24, 2022 15:28
Show Gist options
  • Save mshakhomirov/b1f442a296ffef52c7baa1245e1dc316 to your computer and use it in GitHub Desktop.
Save mshakhomirov/b1f442a296ffef52c7baa1245e1dc316 to your computer and use it in GitHub Desktop.
with events as (
select 'open_chat' as event_name, '10.1.0' as app_display_version union all
select 'open_chat' as event_name, '10.1.9' as app_display_version union all
select 'open_chat' as event_name, '9.1.4' as app_display_version union all
select 'open_chat' as event_name, '9.0.0' as app_display_version
)
select
app_display_version
,REGEXP_EXTRACT(app_display_version, '^[^.^]*') main_version
,safe_cast(REGEXP_EXTRACT(app_display_version, '[0-9]+.[0-9]+') as float64) release_version
,safe_cast(REGEXP_EXTRACT(app_display_version, r"^[a-zA-Z0-9_.+-]+.[a-zA-Z0-9-]+\.([a-zA-Z0-9-.]+$)") as int64) as mod_version
from events
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment