private void validateModality ( SqlNode query ) { final SqlModality modality = deduceModality ( query ) ; if ( query instanceof SqlSelect ) { final SqlSelect select = ( SqlSelect ) query ; validateModality ( select , modality , true ) ; } else if ( query . getKind ( ) == SqlKind . VALUES ) { switch ( modality ) { case STREAM : throw newValidationError ( query , Static . RESOURCE . cannotStreamValues ( ) ) ; } } else { assert query . isA ( SqlKind . SET_QUERY ) ; final SqlCall call = ( SqlCall ) query ; for ( SqlNode operand : call . getOperandList ( ) ) { if ( deduceModality ( operand ) != modality ) { throw newValidationError ( operand , Static . RESOURCE . streamSetOpInconsistentInputs ( ) ) ; } validateModality ( operand ) ; } } }
Validates that a query can deliver the modality it promises . Only called on the top - most SELECT or set operator in the tree .