| 78 | }() |
| 79 | |
| 80 | VectorPtr CastExpr::applyMap( |
| 81 | const SelectivityVector& rows, |
| 82 | const MapVector* input, |
| 83 | exec::EvalCtx& context, |
| 84 | const MapType& fromType, |
| 85 | const MapType& toType) { |
| 86 | // Cast input keys/values vector to output keys/values vector using their |
| 87 | // element selectivity vector |
| 88 | |
| 89 | // Initialize nested rows |
| 90 | auto mapKeys = input->mapKeys(); |
| 91 | auto mapValues = input->mapValues(); |
| 92 | |
| 93 | SelectivityVector nestedRows; |
| 94 | BufferPtr elementToTopLevelRows; |
| 95 | if (fromType.keyType() != toType.keyType() || |
| 96 | fromType.valueType() != toType.valueType()) { |
| 97 | nestedRows = functions::toElementRows(mapKeys->size(), rows, input); |
| 98 | elementToTopLevelRows = functions::getElementToTopLevelRows( |
| 99 | mapKeys->size(), rows, input, context.pool()); |
| 100 | } |
| 101 | |
| 102 | ErrorVectorPtr oldErrors; |
| 103 | context.swapErrors(oldErrors); |
| 104 | |
| 105 | // Cast keys |
| 106 | VectorPtr newMapKeys; |
| 107 | if (fromType.keyType() == toType.keyType()) { |
| 108 | newMapKeys = input->mapKeys(); |
| 109 | } else { |
| 110 | { |
| 111 | ScopedVarSetter holder(&inTopLevel, false); |
| 112 | apply( |
| 113 | nestedRows, |
| 114 | mapKeys, |
| 115 | context, |
| 116 | fromType.keyType(), |
| 117 | toType.keyType(), |
| 118 | newMapKeys); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | // Cast values |
| 123 | VectorPtr newMapValues; |
| 124 | if (fromType.valueType() == toType.valueType()) { |
| 125 | newMapValues = mapValues; |
| 126 | } else { |
| 127 | { |
| 128 | ScopedVarSetter holder(&inTopLevel, false); |
| 129 | apply( |
| 130 | nestedRows, |
| 131 | mapValues, |
| 132 | context, |
| 133 | fromType.valueType(), |
| 134 | toType.valueType(), |
| 135 | newMapValues); |
| 136 | } |
| 137 | } |
nothing calls this directly
no test coverage detected