Skip to content

Commit

Permalink
Fix trim trailing error (#11085)
Browse files Browse the repository at this point in the history
* Fix trim trailing error

* reduce substr logic using negative end index

* Update clickhouse.sql

---------

Co-authored-by: Robert Sheridan <[email protected]>
  • Loading branch information
fuzhaoyuan and sheridancbio authored Oct 24, 2024
1 parent 007de21 commit b2ce990
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/resources/db-scripts/clickhouse/clickhouse.sql
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ FROM
(SELECT
g.hugo_gene_symbol AS hugo_gene_symbol,
gp.stable_id as stable_id,
arrayMap(x -> (x = '' ? NULL : x), splitByString(',', assumeNotNull(trim(trailing ',' from ga.values)))) AS alteration_value,
arrayMap(x -> (x = '' ? NULL : toInt32(x)), splitByString(',', assumeNotNull(trim(trailing ',' from gps.ordered_sample_list)))) AS sample_id
arrayMap(x -> (x = '' ? NULL : x), splitByString(',', assumeNotNull(substring(ga.values, 1, -1)))) AS alteration_value,
arrayMap(x -> (x = '' ? NULL : toInt32(x)), splitByString(',', assumeNotNull(substring(gps.ordered_sample_list, 1, -1)))) AS sample_id
FROM
genetic_profile gp
JOIN genetic_profile_samples gps ON gp.genetic_profile_id = gps.genetic_profile_id
Expand Down Expand Up @@ -372,8 +372,8 @@ FROM
ge.stable_id as entity_stable_id,
gp.datatype as datatype,
gp.patient_level as patient_level,
arrayMap(x -> (x = '' ? NULL : x), splitByString(',', assumeNotNull(trim(trailing ',' from ga.values)))) AS value,
arrayMap(x -> (x = '' ? NULL : toInt64(x)), splitByString(',', assumeNotNull(trim(trailing ',' from gps.ordered_sample_list)))) AS sample_id
arrayMap(x -> (x = '' ? NULL : x), splitByString(',', assumeNotNull(substring(ga.values, 1, -1)))) AS value,
arrayMap(x -> (x = '' ? NULL : toInt64(x)), splitByString(',', assumeNotNull(substring(gps.ordered_sample_list, 1, -1)))) AS sample_id
FROM genetic_profile gp
JOIN genetic_profile_samples gps ON gp.genetic_profile_id = gps.genetic_profile_id
JOIN genetic_alteration ga ON gp.genetic_profile_id = ga.genetic_profile_id
Expand Down

0 comments on commit b2ce990

Please sign in to comment.