|
403 | 403 | ( |
404 | 404 | WITH <include refid="org.cbioportal.infrastructure.repository.clickhouse.studyview.ClickhouseStudyViewFilterMapper.studyAttributeFilterCTEs"/>, |
405 | 405 | study_attribute_levels AS ( |
406 | | - SELECT DISTINCT cancer_study_identifier |
407 | | - FROM clinical_data_derived |
408 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
409 | | - AND type='${type}' |
| 406 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 407 | + FROM clinical_attribute_meta cam |
| 408 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 409 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
| 410 | + AND cam.patient_attribute = IF('${type}' = 'patient', 1, 0) |
410 | 411 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
411 | | - AND cancer_study_identifier IN |
| 412 | + AND cs.cancer_study_identifier IN |
412 | 413 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
413 | 414 | #{studyId} |
414 | 415 | </foreach> |
|
480 | 481 |
|
481 | 482 | <sql id="studyAttributeFilterCTEs"> |
482 | 483 | study_with_attribute AS ( |
483 | | - SELECT DISTINCT cancer_study_identifier |
484 | | - FROM clinical_data_derived |
485 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
| 484 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 485 | + FROM clinical_attribute_meta cam |
| 486 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 487 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
486 | 488 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
487 | | - AND cancer_study_identifier IN |
| 489 | + AND cs.cancer_study_identifier IN |
488 | 490 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
489 | 491 | #{studyId} |
490 | 492 | </foreach> |
491 | 493 | </if> |
492 | 494 | ), |
493 | 495 | study_without_attribute AS ( |
494 | | - SELECT DISTINCT cancer_study_identifier |
495 | | - FROM sample_derived |
496 | | - WHERE cancer_study_identifier NOT IN (SELECT cancer_study_identifier FROM study_with_attribute) |
| 496 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 497 | + FROM cancer_study cs |
| 498 | + WHERE cs.cancer_study_identifier NOT IN (SELECT cancer_study_identifier FROM study_with_attribute) |
497 | 499 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
498 | | - AND cancer_study_identifier IN |
| 500 | + AND cs.cancer_study_identifier IN |
499 | 501 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
500 | 502 | #{studyId} |
501 | 503 | </foreach> |
|
521 | 523 | ( |
522 | 524 | WITH <include refid="org.cbioportal.infrastructure.repository.clickhouse.studyview.ClickhouseStudyViewFilterMapper.studyAttributeFilterCTEs"/>, |
523 | 525 | study_attribute_levels AS ( |
524 | | - SELECT DISTINCT cancer_study_identifier |
525 | | - FROM clinical_data_derived |
526 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
527 | | - AND type='${type}' |
| 526 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 527 | + FROM clinical_attribute_meta cam |
| 528 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 529 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
| 530 | + AND cam.patient_attribute = IF('${type}' = 'patient', 1, 0) |
528 | 531 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
529 | | - AND cancer_study_identifier IN |
| 532 | + AND cs.cancer_study_identifier IN |
530 | 533 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
531 | 534 | #{studyId} |
532 | 535 | </foreach> |
|
0 commit comments