| 135 | } |
| 136 | |
| 137 | void SchemaEvolution::buildConversion(const Type* readType, const Type* fileType) { |
| 138 | if (fileType == nullptr) { |
| 139 | throw SchemaEvolutionError("File does not have " + readType->toString()); |
| 140 | } |
| 141 | |
| 142 | auto [valid, convert] = checkConversion(*readType, *fileType); |
| 143 | if (!valid) { |
| 144 | invalidConversion(readType, fileType); |
| 145 | } |
| 146 | readTypeMap_.emplace(readType->getColumnId(), convert ? readType : fileType); |
| 147 | |
| 148 | // check whether PPD conversion is safe |
| 149 | buildSafePPDConversionMap(readType, fileType); |
| 150 | |
| 151 | for (uint64_t i = 0; i < readType->getSubtypeCount(); ++i) { |
| 152 | auto subType = readType->getSubtype(i); |
| 153 | if (subType) { |
| 154 | // null subType means that this is a sub column of map/list type |
| 155 | // and it does not exist in the file. simply skip it. |
| 156 | buildConversion(subType, fileType->getTypeByColumnId(subType->getColumnId())); |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | bool SchemaEvolution::needConvert(const Type& fileType) const { |
| 162 | auto _readType = getReadType(fileType); |
nothing calls this directly
no test coverage detected