|
435 | 435 | ( |
436 | 436 | WITH <include refid="org.cbioportal.infrastructure.repository.clickhouse.studyview.ClickhouseStudyViewFilterMapper.studyAttributeFilterCTEs"/>, |
437 | 437 | study_attribute_levels AS ( |
438 | | - SELECT DISTINCT cancer_study_identifier |
439 | | - FROM clinical_data_derived |
440 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
441 | | - AND type='${type}' |
| 438 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 439 | + FROM clinical_attribute_meta cam |
| 440 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 441 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
| 442 | + AND cam.patient_attribute = IF('${type}' = 'patient', 1, 0) |
442 | 443 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
443 | | - AND cancer_study_identifier IN |
| 444 | + AND cs.cancer_study_identifier IN |
444 | 445 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
445 | 446 | #{studyId} |
446 | 447 | </foreach> |
|
512 | 513 |
|
513 | 514 | <sql id="studyAttributeFilterCTEs"> |
514 | 515 | study_with_attribute AS ( |
515 | | - SELECT DISTINCT cancer_study_identifier |
516 | | - FROM clinical_data_derived |
517 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
| 516 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 517 | + FROM clinical_attribute_meta cam |
| 518 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 519 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
518 | 520 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
519 | | - AND cancer_study_identifier IN |
| 521 | + AND cs.cancer_study_identifier IN |
520 | 522 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
521 | 523 | #{studyId} |
522 | 524 | </foreach> |
523 | 525 | </if> |
524 | 526 | ), |
525 | 527 | study_without_attribute AS ( |
526 | | - SELECT DISTINCT cancer_study_identifier |
527 | | - FROM sample_derived |
528 | | - WHERE cancer_study_identifier NOT IN (SELECT cancer_study_identifier FROM study_with_attribute) |
| 528 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 529 | + FROM cancer_study cs |
| 530 | + WHERE cs.cancer_study_identifier NOT IN (SELECT cancer_study_identifier FROM study_with_attribute) |
529 | 531 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
530 | | - AND cancer_study_identifier IN |
| 532 | + AND cs.cancer_study_identifier IN |
531 | 533 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
532 | 534 | #{studyId} |
533 | 535 | </foreach> |
|
553 | 555 | ( |
554 | 556 | WITH <include refid="org.cbioportal.infrastructure.repository.clickhouse.studyview.ClickhouseStudyViewFilterMapper.studyAttributeFilterCTEs"/>, |
555 | 557 | study_attribute_levels AS ( |
556 | | - SELECT DISTINCT cancer_study_identifier |
557 | | - FROM clinical_data_derived |
558 | | - WHERE attribute_name = #{clinicalDataFilter.attributeId} |
559 | | - AND type='${type}' |
| 558 | + SELECT DISTINCT cs.cancer_study_identifier as cancer_study_identifier |
| 559 | + FROM clinical_attribute_meta cam |
| 560 | + INNER JOIN cancer_study cs ON cam.cancer_study_id = cs.cancer_study_id |
| 561 | + WHERE cam.attr_id = #{clinicalDataFilter.attributeId} |
| 562 | + AND cam.patient_attribute = IF('${type}' = 'patient', 1, 0) |
560 | 563 | <if test="studyViewFilterContext.customDataFilterCancerStudies != null and !studyViewFilterContext.customDataFilterCancerStudies.isEmpty()"> |
561 | | - AND cancer_study_identifier IN |
| 564 | + AND cs.cancer_study_identifier IN |
562 | 565 | <foreach item="studyId" collection="studyViewFilterContext.customDataFilterCancerStudies" open="(" separator="," close=")"> |
563 | 566 | #{studyId} |
564 | 567 | </foreach> |
|
0 commit comments