Skip to content

Commit

Permalink
Update generic assay table schema
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhaoyuan committed Nov 11, 2024
1 parent 3f7b42f commit f59044a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/main/resources/db-scripts/clickhouse/clickhouse.sql
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ FROM
CREATE TABLE IF NOT EXISTS generic_assay_data_derived
(
sample_unique_id String,
patient_unique_id String,
genetic_entity_id String,
value String,
generic_assay_type String,
profile_stable_id String,
entity_stable_id String,
datatype String,
patient_level NUMERIC,
profile_type String
)
ENGINE = MergeTree()
Expand All @@ -348,13 +348,13 @@ CREATE TABLE IF NOT EXISTS generic_assay_data_derived
INSERT INTO TABLE generic_assay_data_derived
SELECT
sd.sample_unique_id as sample_unique_id,
sd.patient_unique_id as patient_unique_id,
genetic_entity_id,
value,
generic_assay_type,
profile_stable_id,
entity_stable_id,
datatype,
patient_level,
replaceOne(profile_stable_id, concat(cs.cancer_study_identifier, '_'), '') as profile_type
FROM
(SELECT
Expand All @@ -366,7 +366,6 @@ FROM
genetic_profile_id,
profile_stable_id,
entity_stable_id,
patient_level,
datatype
FROM
(SELECT
Expand All @@ -378,7 +377,6 @@ FROM
gp.stable_id as profile_stable_id,
ge.stable_id as entity_stable_id,
gp.datatype as datatype,
gp.patient_level as patient_level,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@

<sql id="selectAllGenericAssays">
SELECT sample_unique_id, patient_unique_id, value, datatype
FROM generic_assay_data_derived_patient
FROM generic_assay_data_derived
WHERE profile_type = #{genericAssayDataFilter.profileType}
AND entity_stable_id = #{genericAssayDataFilter.stableId}
</sql>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
entity_stable_id AS stableId,
value,
cast(count(*) AS INTEGER) AS count
FROM generic_assay_data_derived_patient
FROM generic_assay_data_derived
<where>
<!-- Table creation in clickhouse.sql has ensured no NA values but extra caution is always appreciated -->
<include refid="normalizeAttributeValue">
Expand Down Expand Up @@ -723,7 +723,7 @@
<property name="attribute_value" value="value"/>
</include> AS value,
cast(count(value) as INTEGER) AS count
FROM generic_assay_data_derived_patient
FROM generic_assay_data_derived
<where>
<!-- Need to ensure no NA values -->
<include refid="normalizeAttributeValue">
Expand Down

0 comments on commit f59044a

Please sign in to comment.